commit - 748c56414eacb7da522137c3ddb35c23e46d526e
commit + 8d0dceb3d76a815a8fbae32091159f8db5672d86
blob - 2f2d51be710c9d1ff0291d1284b33f43eb85e145
blob + 2dcb63267e36d94e9cdff8cf736147e2ded5f199
--- got/got.1
+++ got/got.1
file of the local repository, as created by
.Cm got clone .
.Pp
+By default, any branches configured in
+.Xr got.conf 5
+for the
+.Ar remote-repository
+will be fetched.
+If
+.Cm got fetch
+is invoked in a work tree then this work tree's current branch will be
+fetched, too, provided it is present on the server.
+This default behaviour can be overridden with the
+.Fl a
+and
+.Fl b
+options.
+If no branches to fetch can be found in
+.Xr got.conf 5 ,
+on the command line, or via a work tree, a branch resolved via the remote
+repository's HEAD reference will be fetched.
+.Pp
New changes will be stored in a separate pack file downloaded from the server.
Optionally, separate pack files stored in the repository can be combined with
.Xr git-repack 1 .
reference namespace.
This option can be enabled by default for specific repositories in
.Xr got.conf 5 .
-If this option is not specified, the work tree's current branch
-will be fetched if invoked within a work tree,
-otherwise a branch resolved via the remote repository's HEAD reference
-will be fetched.
Cannot be used together with the
.Fl b
option.
reference namespace.
This option may be specified multiple times to build a list of branches
to fetch.
-If this option is not specified, the work tree's current branch
-will be fetched if invoked within a work tree,
-otherwise a branch resolved via the remote repository's HEAD reference
-will be fetched.
Cannot be used together with the
.Fl a
option.
blob - d9d48662f28e288f700a39e53e8c64c25dd28233
blob + 3ac49dee22958ea411f59d158f6ea214f35f798f
--- got/got.c
+++ got/got.c
break;
}
}
- }
- if (TAILQ_EMPTY(&wanted_branches)) {
- error = got_pathlist_append(&wanted_branches,
- got_worktree_get_head_ref_name(worktree), NULL);
- if (error)
- goto done;
}
}
if (remote == NULL) {
for (i = 0; i < remote->nfetch_branches; i++) {
error = got_pathlist_append(&wanted_branches,
remote->fetch_branches[i], NULL);
+ if (error)
+ goto done;
+ }
+ if (worktree) {
+ error = got_pathlist_append(&wanted_branches,
+ got_worktree_get_head_ref_name(worktree), NULL);
if (error)
goto done;
}
blob - 0211785dcc6e7adad10d1a2d594bcda72bf2efa7
blob + 0f381607476a2ed62e00ff9cb319557a26e8d633
--- regress/cmdline/fetch.sh
+++ regress/cmdline/fetch.sh
git_commit $testroot/repo -m "modified alpha"
local commit_id3=`git_show_head $testroot/repo`
+ # foo is now the default HEAD branch in $testroot/repo
+ # but got.conf still says to fetch "master"
got fetch -q -r $testroot/repo-clone -b foo > $testroot/stdout
ret=$?
if [ $ret -ne 0 ]; then
return 1
fi
- got fetch -q -r $testroot/repo-clone -b master > $testroot/stdout
+ # got.conf tells us to fetch the 'master' branch by default
+ got fetch -q -r $testroot/repo-clone > $testroot/stdout
ret=$?
if [ $ret -ne 0 ]; then
echo "got fetch command failed unexpectedly" >&2
git_commit $testroot/repo -m "modified beta"
local commit_id4=`git_show_head $testroot/repo`
+ # set the default HEAD branch back to master
+ (cd $testroot/repo && git checkout -q master)
+
got checkout -b foo $testroot/repo-clone $testroot/wt > /dev/null
# fetch new commits on branch 'foo', implicitly obtaining the
>> $testroot/stdout.expected
echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected
echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
- echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \
+ echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \
>> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id4" >> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id2" \