commit - 1fddf795d370eab80e6b2a3e502a6e7e89c9e963
commit + 56d0a75325a6ada09ad4f1c586f7fde7971b52f6
blob - 588f144e15210cef646e4d3b143f8cb74e7e5abe
blob + 47e8801b98449d0d980a504de018d37c45183fc7
--- got/got.c
+++ got/got.c
char *gitconfig = NULL;
FILE *gitconfig_file = NULL;
char *branches = NULL, *refs = NULL;
- const char *branchname, *mirror = NULL;
+ const char *branchname;
ssize_t n;
/* Create a config file Git can understand. */
err = got_error_from_errno2("fopen", gitconfig_path);
goto done;
}
- if (mirror_references) {
- mirror = "\tmirror = true\n";
- branches = strdup("\tfetch = +refs/*:refs/*\n");
- if (branches == NULL) {
- err = got_error_from_errno("strdup");
- goto done;
- }
- } else if (fetch_all_branches) {
- if (asprintf(&branches,
- "\tfetch = +refs/heads/*:refs/remotes/%s/*\n",
+ if (fetch_all_branches) {
+ if (mirror_references) {
+ if (asprintf(&branches,
+ "\tfetch = refs/heads/*:refs/heads/*\n") == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
+ } else if (asprintf(&branches,
+ "\tfetch = refs/heads/*:refs/remotes/%s/*\n",
GOT_FETCH_DEFAULT_REMOTE_NAME) == -1) {
err = got_error_from_errno("asprintf");
goto done;
branchname = pe->path;
if (strncmp(branchname, "refs/heads/", 11) == 0)
branchname += 11;
- if (asprintf(&s,
- "%s\tfetch = +refs/heads/%s:refs/remotes/%s/%s\n",
+ if (mirror_references) {
+ if (asprintf(&s,
+ "%s\tfetch = refs/heads/%s:refs/heads/%s\n",
+ branches ? branches : "",
+ branchname, branchname) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
+ } else if (asprintf(&s,
+ "%s\tfetch = refs/heads/%s:refs/remotes/%s/%s\n",
branches ? branches : "",
branchname, GOT_FETCH_DEFAULT_REMOTE_NAME,
branchname) == -1) {
branchname += 11;
} else
branchname = "*"; /* fall back to all branches */
- if (asprintf(&branches,
- "\tfetch = +refs/heads/%s:refs/remotes/%s/%s\n",
+ if (mirror_references) {
+ if (asprintf(&branches,
+ "\tfetch = refs/heads/%s:refs/heads/%s\n",
+ branchname, branchname) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
+ } else if (asprintf(&branches,
+ "\tfetch = refs/heads/%s:refs/remotes/%s/%s\n",
branchname, GOT_FETCH_DEFAULT_REMOTE_NAME,
branchname) == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
}
- if (!mirror_references && !TAILQ_EMPTY(wanted_refs)) {
+ if (!TAILQ_EMPTY(wanted_refs)) {
struct got_pathlist_entry *pe;
TAILQ_FOREACH(pe, wanted_refs, entry) {
char *s;
const char *refname = pe->path;
if (strncmp(refname, "refs/", 5) == 0)
refname += 5;
- if (asprintf(&s,
- "%s\tfetch = +refs/%s:refs/remotes/%s/%s\n",
+ if (mirror_references) {
+ if (asprintf(&s,
+ "%s\tfetch = refs/%s:refs/%s\n",
+ refs ? refs : "", refname, refname) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
+ } else if (asprintf(&s,
+ "%s\tfetch = refs/%s:refs/remotes/%s/%s\n",
refs ? refs : "",
refname, GOT_FETCH_DEFAULT_REMOTE_NAME,
refname) == -1) {
"\turl = %s\n"
"%s"
"%s"
- "%s",
+ "\tfetch = refs/tags/*:refs/tags/*\n",
GOT_FETCH_DEFAULT_REMOTE_NAME, git_url, branches ? branches : "",
- refs ? refs : "", mirror ? mirror : "") == -1) {
+ refs ? refs : "") == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
blob - 44c5e030d3c0d68974cecd35b85f6edabc096ee3
blob + 0e24ae3c91470f97788ef2e7a418a85ac613d339
--- regress/cmdline/clone.sh
+++ regress/cmdline/clone.sh
[remote "origin"]
url = ssh://127.0.0.1$testroot/repo
- fetch = +refs/heads/master:refs/remotes/origin/master
+ fetch = refs/heads/master:refs/remotes/origin/master
+ fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
ret="$?"
[remote "origin"]
url = ssh://127.0.0.1$testroot/repo
- fetch = +refs/heads/foo:refs/remotes/origin/foo
+ fetch = refs/heads/foo:refs/remotes/origin/foo
+ fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
ret="$?"
[remote "origin"]
url = ssh://127.0.0.1$testroot/repo
- fetch = +refs/heads/*:refs/remotes/origin/*
+ fetch = refs/heads/*:refs/remotes/origin/*
+ fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
ret="$?"
[remote "origin"]
url = ssh://127.0.0.1$testroot/repo
- fetch = +refs/*:refs/*
- mirror = true
+ fetch = refs/heads/master:refs/heads/master
+ fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
ret="$?"
[remote "origin"]
url = ssh://127.0.0.1$testroot/repo
- fetch = +refs/*:refs/*
- mirror = true
+ fetch = refs/heads/*:refs/heads/*
+ fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
ret="$?"
[remote "origin"]
url = ssh://127.0.0.1$testroot/repo
- fetch = +refs/heads/master:refs/remotes/origin/master
- fetch = +refs/hoo:refs/remotes/origin/hoo
+ fetch = refs/heads/master:refs/remotes/origin/master
+ fetch = refs/hoo:refs/remotes/origin/hoo
+ fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
ret="$?"
[remote "origin"]
url = ssh://127.0.0.1$testroot/repo
- fetch = +refs/heads/foo:refs/remotes/origin/foo
- fetch = +refs/hoo/boo/zoo:refs/remotes/origin/hoo/boo/zoo
+ fetch = refs/heads/foo:refs/remotes/origin/foo
+ fetch = refs/hoo/boo/zoo:refs/remotes/origin/hoo/boo/zoo
+ fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
ret="$?"
[remote "origin"]
url = ssh://127.0.0.1$testroot/repo
- fetch = +refs/*:refs/*
- mirror = true
+ fetch = refs/heads/master:refs/heads/master
+ fetch = refs/hoo:refs/hoo
+ fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
ret="$?"
[remote "origin"]
url = ssh://127.0.0.1$testroot/repo
- fetch = +refs/heads/foo:refs/remotes/origin/foo
- fetch = +refs/heads/bar:refs/remotes/origin/bar
+ fetch = refs/heads/foo:refs/remotes/origin/foo
+ fetch = refs/heads/bar:refs/remotes/origin/bar
+ fetch = refs/tags/*:refs/tags/*
EOF
cmp -s $testroot/repo-clone/config $testroot/config.expected
ret="$?"