commit - 7a90b6809c18acd607a3ff752bb9a2462317c1f5
commit + 15d3c221e34cad474e87c43111417186822c887c
blob - 0d05ef480cf0480004133b98b02d8a976c0dfbfb
blob + 84e6393a0ccccffa54f45e6a0864788439cbf871
--- got/got.1
+++ got/got.1
.Pa config
files of the cloned repository to store the
.Ar repository-url
+and
+.Ar branch
for future use by
.Cm got fetch
or
blob - 992f88fac5a3fcebfaabed859563cbf5a8498e4f
blob + 1a0fbb720f4427b7c07a93e638a484560ec1d37b
--- got/got.c
+++ got/got.c
static const struct got_error *
create_gotconfig(const char *proto, const char *host, const char *port,
- const char *remote_repo_path, int fetch_all_branches, int mirror_references,
- struct got_repository *repo)
+ const char *remote_repo_path, const char *default_branch,
+ int fetch_all_branches, int mirror_references, struct got_repository *repo)
{
const struct got_error *err = NULL;
char *gotconfig_path = NULL;
char *gotconfig = NULL;
FILE *gotconfig_file = NULL;
+ const char *branchname = NULL;
ssize_t n;
+ if (default_branch) {
+ branchname = default_branch;
+ if (strncmp(branchname, "refs/heads/", 11) == 0)
+ branchname += 11;
+ }
+
/* Create got.conf(5). */
gotconfig_path = got_repo_get_path_gotconfig(repo);
if (gotconfig_path == NULL) {
"\tprotocol %s\n"
"%s%s%s"
"\trepository \"%s\"\n"
+ "%s%s%s"
"%s"
"}\n",
GOT_FETCH_DEFAULT_REMOTE_NAME, host, proto,
port ? "\tport " : "", port ? port : "", port ? "\n" : "",
remote_repo_path,
+ branchname ? "\tbranch { \"" : "",
+ branchname ? branchname : "",
+ branchname ? "\" }\n" : "",
mirror_references ? "\tmirror-references yes\n" : "") == -1) {
err = got_error_from_errno("asprintf");
goto done;
/* Create got.conf(5). */
err = create_gotconfig(proto, host, port, remote_repo_path,
- fetch_all_branches, mirror_references, repo);
+ default_branch, fetch_all_branches, mirror_references, repo);
if (err)
return err;
blob - 090d275c54ed17e7ed475a292bfd074d1b4cec35
blob + 256c4fc96eab70d803e3a8535f61ceb993785db3
--- regress/cmdline/clone.sh
+++ regress/cmdline/clone.sh
server 127.0.0.1
protocol ssh
repository "$testroot/repo"
+ branch { "master" }
}
EOF
cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
server 127.0.0.1
protocol ssh
repository "$testroot/repo"
+ branch { "foo" }
}
EOF
cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
server 127.0.0.1
protocol ssh
repository "$testroot/repo"
+ branch { "master" }
}
EOF
cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
server 127.0.0.1
protocol ssh
repository "$testroot/repo"
+ branch { "master" }
mirror-references yes
}
EOF
server 127.0.0.1
protocol ssh
repository "$testroot/repo"
+ branch { "master" }
mirror-references yes
}
EOF
server 127.0.0.1
protocol ssh
repository "$testroot/repo"
+ branch { "master" }
}
EOF
cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
server 127.0.0.1
protocol ssh
repository "$testroot/repo"
+ branch { "foo" }
}
EOF
cmp -s $testroot/repo-clone/got.conf $testroot/got.conf.expected
server 127.0.0.1
protocol ssh
repository "$testroot/repo"
+ branch { "master" }
mirror-references yes
}
EOF
blob - 86e2e5c79aab3d66e535352f2a388f4103e8a551
blob + 1fc5c95a555dfce8b88c9df9c019ea1ae8d57848
--- regress/cmdline/fetch.sh
+++ regress/cmdline/fetch.sh
got ref -l -r $testroot/repo-clone > $testroot/stdout
echo "HEAD: refs/heads/master" > $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/master: $commit_id" \
+ >> $testroot/stdout.expected
+
+ cmp -s $testroot/stdout $testroot/stdout.expected
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ got fetch -q -r $testroot/repo-clone -a
+
+ 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/foo" \