commit 8b5c397a986e28b7e29988879d382a39027f8ed3a16d96bb01da09e466a02e7c 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 - 1a201d3a3d7a268be170cb71688ea1d7d0ca79523076f50ff5a423f7806397dd commit + 8b5c397a986e28b7e29988879d382a39027f8ed3a16d96bb01da09e466a02e7c blob - 18dfd24d46c393580d4aaaa55d31fbda699118f666ab268ce87ea9c1ba3eb374 blob + 09f73d128be7394226b37c83bb9a6501f148597b7ad640910d9d16f834117c71 --- 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 - 74d24f12e750bb8ea0cf0e6f52b95c3e2485d10776482bc5bae849ee1fc53a2a blob + 0cef34ecd4d8443662062bd91ba16202e4b92eb166d8b2bcf14bc97bea072f3d --- 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 - 0018862da4eae0ac26fae39ee326c8f08450f26e2fde0e7747332a096935a4be blob + d78b90d69e94a6e24d03531abf2f64d646bd412c939a53baddd7ae076c5fe274 --- 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