commit - 75236079c0b50ee24defebe1509f537bae91aefe
commit + f298ae0fb8ef2fb3645ac256d8e968d564be275e
blob - 88e00352743c1793902d7950c2ab3bdd10f581be
blob + b02072bccaf3d9b6fd8fbcc856402702d6307ba0
--- got/got.c
+++ got/got.c
}
static const struct got_error *
-create_head_ref(struct got_reference *target_ref, int verbosity,
- struct got_repository *repo)
+create_symref(const char *refname, struct got_reference *target_ref,
+ int verbosity, struct got_repository *repo)
{
const struct got_error *err;
struct got_reference *head_symref;
- err = got_ref_alloc_symref(&head_symref, GOT_REF_HEAD, target_ref);
+ err = got_ref_alloc_symref(&head_symref, refname, target_ref);
if (err)
return err;
goto done;
}
error = create_ref(remote_refname, id, verbosity - 1, repo);
+ free(remote_refname);
if (error)
goto done;
}
struct got_reference *target_ref;
const char *refname = pe->path;
const char *target = pe->data;
+ char *remote_refname = NULL, *remote_target = NULL;
if (strcmp(refname, GOT_REF_HEAD) != 0)
continue;
goto done;
}
- error = create_head_ref(target_ref, verbosity, repo);
+ error = create_symref(refname, target_ref, verbosity, repo);
+ got_ref_close(target_ref);
+ if (error)
+ goto done;
+
+ if (mirror_references)
+ continue;
+
+ if (strncmp("refs/heads/", target, 11) != 0)
+ continue;
+
+ if (asprintf(&remote_refname,
+ "refs/remotes/%s/%s", GOT_FETCH_DEFAULT_REMOTE_NAME,
+ refname) == -1) {
+ error = got_error_from_errno("asprintf");
+ goto done;
+ }
+ if (asprintf(&remote_target,
+ "refs/remotes/%s/%s", GOT_FETCH_DEFAULT_REMOTE_NAME,
+ target + 11) == -1) {
+ error = got_error_from_errno("asprintf");
+ free(remote_refname);
+ goto done;
+ }
+ error = got_ref_open(&target_ref, repo, remote_target, 0);
+ if (error) {
+ free(remote_refname);
+ free(remote_target);
+ if (error->code == GOT_ERR_NOT_REF) {
+ error = NULL;
+ continue;
+ }
+ goto done;
+ }
+ error = create_symref(remote_refname, target_ref,
+ verbosity - 1, repo);
+ free(remote_refname);
+ free(remote_target);
got_ref_close(target_ref);
if (error)
goto done;
goto done;
}
- error = create_head_ref(target_ref, verbosity, repo);
+ error = create_symref(GOT_REF_HEAD, target_ref,
+ verbosity, repo);
got_ref_close(target_ref);
if (error)
goto done;
blob - 446d7b73e9428139a538555e3c55ae5786cb6eb8
blob + b188613f5c0ab1301b667f94dfbc18bea0f8512c
--- regress/cmdline/clone.sh
+++ regress/cmdline/clone.sh
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
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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id" \
>> $testroot/stdout.expected
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/hoo/boo/zoo: $commit_id" \
>> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id" \
blob - fb811d10678197846f753b9591a2ea121483ebc1
blob + 404c994afe6baff215d08dc8f14a1f9437434dac
--- regress/cmdline/fetch.sh
+++ regress/cmdline/fetch.sh
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_id2" \
>> $testroot/stdout.expected
echo "HEAD: refs/heads/master" > $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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
# refs/remotes/origin/master is umodified because it wasn't fetched
echo "refs/remotes/origin/master: $commit_id" \
echo "HEAD: refs/heads/master" > $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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id3" >> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id2" \
>> $testroot/stdout.expected
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
# refs/hoo/boo/zoo is missing because it is outside of refs/heads
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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id" \
>> $testroot/stdout.expected
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
# refs/hoo/boo/zoo is missing because it is outside of refs/heads
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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id" \
>> $testroot/stdout.expected
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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id" \
>> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id" \
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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id" \
>> $testroot/stdout.expected
echo "HEAD: refs/heads/master" > $testroot/stdout.expected
# refs/heads/foo is now deleted
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/foo: $commit_id" >> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id" \
>> $testroot/stdout.expected
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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id" \
>> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id" \
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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id2" \
>> $testroot/stdout.expected
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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id2" \
>> $testroot/stdout.expected
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/master" \
+ >> $testroot/stdout.expected
echo "refs/remotes/origin/foo: $commit_id" >> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id2" \
>> $testroot/stdout.expected
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/hoo/boo/zoo: $commit_id" \
>> $testroot/stdout.expected
echo "refs/remotes/origin/master: $commit_id2" \