commit 67e1bc05349929c2485ed00e3aa04272da0cabd8 from: Stefan Sperling date: Sun Aug 17 11:03:26 2025 UTC make 'got clone' set a got.conf default branch for fetching only, not sending This will make 'got send' default to the work tree's current branch or the HEAD reference if not invoked in a work tree, rather than defaulting to sending the default branch found while cloning. Issue pointed out by op@ ok op@ commit - 8df39a000dfa5a10c68b3631e1ad316acd69e111 commit + 67e1bc05349929c2485ed00e3aa04272da0cabd8 blob - 80379bddab5170afe5c0e8cbb9bd21f4d8362982 blob + bd5af8c0b0571f83a5818af322e15e0785dee8f9 --- got/got.c +++ got/got.c @@ -1397,15 +1397,21 @@ create_gotconfig(const char *proto, const char *host, "\tprotocol %s\n" "%s%s%s" "\trepository \"%s\"\n" + "%s" "%s%s%s" + "%s" "%s%s%s" "%s" "%s" "}\n", GOT_FETCH_DEFAULT_REMOTE_NAME, host, proto, port ? "\tport " : "", port ? port : "", port ? "\n" : "", - remote_repo_path, branches ? "\tbranch { " : "", - branches ? branches : "", branches ? "}\n" : "", + remote_repo_path, + branches ? "\tfetch {\n" : "", + branches ? "\t\tbranch { " : "", + branches ? branches : "", + branches ? "}\n" : "", + branches ? "\t}\n" : "", refs ? "\treference { " : "", refs ? refs : "", refs ? "}\n" : "", mirror_references ? "\tmirror_references yes\n" : "", fetch_all_branches ? "\tfetch_all_branches yes\n" : "") == -1) { blob - 184a0cab35d28783c255c1494d78b1695189a105 blob + e9daec23e99eaee20166b09dfb7ebbde29181db1 --- regress/cmdline/clone.sh +++ regress/cmdline/clone.sh @@ -95,7 +95,9 @@ remote "origin" { server 127.0.0.1 protocol ssh repository "$testroot/repo" - branch { "master" } + fetch { + branch { "master" } + } } EOF cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected @@ -226,7 +228,9 @@ remote "origin" { server 127.0.0.1 protocol ssh repository "$testroot/repo" - branch { "foo" } + fetch { + branch { "foo" } + } } EOF cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected @@ -375,7 +379,9 @@ remote "origin" { server 127.0.0.1 protocol ssh repository "$testroot/repo" - branch { "master" } + fetch { + branch { "master" } + } mirror_references yes } EOF @@ -525,7 +531,9 @@ remote "origin" { server 127.0.0.1 protocol ssh repository "$testroot/repo" - branch { "master" } + fetch { + branch { "master" } + } reference { "hoo" } } EOF @@ -601,7 +609,9 @@ remote "origin" { server 127.0.0.1 protocol ssh repository "$testroot/repo" - branch { "foo" } + fetch { + branch { "foo" } + } reference { "hoo/boo/zoo" } } EOF @@ -674,7 +684,9 @@ remote "origin" { server 127.0.0.1 protocol ssh repository "$testroot/repo" - branch { "master" } + fetch { + branch { "master" } + } reference { "hoo" } mirror_references yes } @@ -748,7 +760,9 @@ remote "origin" { server 127.0.0.1 protocol ssh repository "$testroot/repo" - branch { "bar" "foo" } + fetch { + branch { "bar" "foo" } + } } EOF cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected @@ -830,7 +844,9 @@ remote "origin" { server 127.0.0.1 protocol ssh repository "$testroot/repo" - branch { "foo" } + fetch { + branch { "foo" } + } } EOF cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected @@ -975,7 +991,9 @@ remote "origin" { protocol http port $GOT_TEST_HTTP_PORT repository "/repo" - branch { "master" } + fetch { + branch { "master" } + } } EOF cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected blob - 9bda4d3b425e3cfc1eaf1893388d1c2ad82c2065 blob + aac6a219e2b443b516724c8444a2c326b6bdcf49 --- regress/cmdline/fetch.sh +++ regress/cmdline/fetch.sh @@ -485,9 +485,11 @@ test_fetch_all() { # remove default branch from got.conf, fetch all branches ed -s $testroot/repo-clone/got.conf <<-EOF + /fetch {/d /branch {/c fetch_all_branches yes . + /}/d w EOF