"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Fix regression: honor fetch_all_branches again
To:
gameoftrees@openbsd.org
Date:
Sat, 30 Sep 2023 21:24:28 +0200

Download raw body.

Thread
I was wondering why "got fetch" stopped fetching all branches of
FreeBSD src.git.  That was a regression between 0.92 and 0.93.

got_repo_remote_repo_dup() fails to copy fetch_all_branches, which
means "fetch_all_branches yes" in got.conf is ignored.

ok?

-----------------------------------------------
commit 86770e34a698eafcf2372140ac1482ff51909f53 (local)
from: Christian Weisgerber <naddy@mips.inka.de>
date: Sat Sep 30 19:22:41 2023 UTC
 
 honor fetch_all_branches configuration again
 
 Fix a regression in db82695e31945b3ce001a5fb69674c3638622368 where
 the fetch_all_branches configuration setting from got.conf was dropped
 and always defaulted to "no".
 
 Add regression test.
 
diff 1ef7649d68d2231933ee3e0059257bea8f3f8a7f 86770e34a698eafcf2372140ac1482ff51909f53
commit - 1ef7649d68d2231933ee3e0059257bea8f3f8a7f
commit + 86770e34a698eafcf2372140ac1482ff51909f53
blob - c428c4539fe5daebf60dc208642df9cafeb4a217
blob + b3b8dfbf8803c64c39fe81209b84b6fa8fd4d79a
--- lib/repository.c
+++ lib/repository.c
@@ -945,6 +945,8 @@ got_repo_remote_repo_dup(struct got_remote_repo **newp
 
 	new->mirror_references = repo->mirror_references;
 
+	new->fetch_all_branches = repo->fetch_all_branches;
+
 	new->nfetch_branches = repo->nfetch_branches;
 	if (repo->fetch_branches) {
 		new->fetch_branches = calloc(repo->nfetch_branches,
blob - 9691b8c6b78c7f1c45800d06ebdf34bbac31399f
blob + 43b93382975fd45e5fa0e500f6a776d9343347c1
--- regress/cmdline/fetch.sh
+++ regress/cmdline/fetch.sh
@@ -474,6 +474,49 @@ test_fetch_all() {
 	if [ $ret -ne 0 ]; then
 		diff -u $testroot/stdout.expected $testroot/stdout
 	fi
+
+	(cd $testroot/repo && git checkout -q foo)
+	echo "modified beta on foo" > $testroot/repo/beta
+	git_commit $testroot/repo -m "modified beta"
+	local commit_id2=`git_show_head $testroot/repo`
+
+	# set the default HEAD branch back to master
+	(cd $testroot/repo && git checkout -q master)
+
+	# remove default branch from got.conf, fetch all branches
+	ed -s $testroot/repo-clone/got.conf <<-EOF
+	/branch {/c
+	fetch_all_branches yes
+	.
+	w
+	EOF
+
+	got fetch -q -r $testroot/repo-clone
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		echo "got fetch command failed unexpectedly" >&2
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+	
+	got ref -l -r $testroot/repo-clone > $testroot/stdout
+
+	echo "HEAD: refs/heads/master" > $testroot/stdout.expected
+	echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected
+	echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
+	echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
+		>> $testroot/stdout.expected
+	echo "refs/remotes/origin/foo: $commit_id2" >> $testroot/stdout.expected
+	echo "refs/remotes/origin/master: $commit_id" \
+		>> $testroot/stdout.expected
+	# refs/hoo/boo/zoo is missing because it is outside of refs/heads
+	echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected
+
+	cmp -s $testroot/stdout $testroot/stdout.expected
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+	fi
 	test_done "$testroot" "$ret"
 }
 
-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de