commit d7a689ea907503c998ff3b75af65066ce8ec680d from: Christian Weisgerber via: Thomas Adam date: Sun Oct 01 18:48:18 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 corresponding regression test. ok stsp commit - 0097ceb4e430158c1e35f0c951364b1848cd8dab commit + d7a689ea907503c998ff3b75af65066ce8ec680d blob - 7e5e0f7b581f411d9771694a15496eeb78bffb1c blob + 0289e1ab40f4d418978aee837b9923c101a3f3d8 --- lib/repository.c +++ lib/repository.c @@ -940,6 +940,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) { 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" }