commit 107723488a685ddd492f1539cfc13a88a4c34ca1 from: Christian Weisgerber date: Sun Oct 01 09:19:06 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 - 1ef7649d68d2231933ee3e0059257bea8f3f8a7f commit + 107723488a685ddd492f1539cfc13a88a4c34ca1 blob - c428c4539fe5daebf60dc208642df9cafeb4a217 blob + b3b8dfbf8803c64c39fe81209b84b6fa8fd4d79a --- lib/repository.c +++ lib/repository.c @@ -944,6 +944,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" }