diff options
author | Mike Hommey <mh@glandium.org> | 2015-01-19 10:35:07 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-01-21 22:46:59 -0800 |
commit | 33cae5428ab504e318cfac880d59e0bda58590d7 (patch) | |
tree | 5cfe024a40a57248141c4524c47bea043ae885d8 /transport-helper.c | |
parent | 627736ca799edacf13881da7e671964a0afb94b8 (diff) | |
download | git-33cae5428ab504e318cfac880d59e0bda58590d7.tar.gz |
transport-helper: do not request symbolic refs to remote helpersmh/deref-symref-over-helper-transport
A typical remote helper will return a `list` of refs containing a symbolic
ref HEAD, pointing to, e.g. refs/heads/master. In the case of a clone, all
the refs are being requested through `fetch` or `import`, including the
symbolic ref.
While this works properly, in some cases of a fetch, like `git fetch url`
or `git fetch origin HEAD`, or any fetch command involving a symbolic ref
without also fetching the corresponding ref it points to, the fetch command
fails with:
fatal: bad object 0000000000000000000000000000000000000000
error: <remote> did not send all necessary objects
(in the case the remote helper returned '?' values to the `list` command).
This is because there is only one ref given to fetch(), and it's not
further resolved to something at the end of fetch_with_import().
While this can be somehow handled in the remote helper itself, by adding
a refspec for the symbolic ref, and storing an explicit ref in a private
namespace, and then handling the `import` for that symbolic ref
specifically, very few existing remote helpers are actually doing that.
So, instead of requesting the exact list of wanted refs to remote helpers,
treat symbolic refs differently and request the ref they point to instead.
Then, resolve the symbolic refs values based on the pointed ref.
This assumes there is no more than one level of indirection (a symbolic
ref doesn't point to another symbolic ref).
Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport-helper.c')
-rw-r--r-- | transport-helper.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/transport-helper.c b/transport-helper.c index 0224687a23..27c82f73ac 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -356,7 +356,8 @@ static int fetch_with_fetch(struct transport *transport, continue; strbuf_addf(&buf, "fetch %s %s\n", - sha1_to_hex(posn->old_sha1), posn->name); + sha1_to_hex(posn->old_sha1), + posn->symref ? posn->symref : posn->name); } strbuf_addch(&buf, '\n'); @@ -454,7 +455,8 @@ static int fetch_with_import(struct transport *transport, if (posn->status & REF_STATUS_UPTODATE) continue; - strbuf_addf(&buf, "import %s\n", posn->name); + strbuf_addf(&buf, "import %s\n", + posn->symref ? posn->symref : posn->name); sendline(data, &buf); strbuf_reset(&buf); } @@ -487,14 +489,15 @@ static int fetch_with_import(struct transport *transport, * fast-forward or this is a forced update. */ for (i = 0; i < nr_heads; i++) { - char *private; + char *private, *name; posn = to_fetch[i]; if (posn->status & REF_STATUS_UPTODATE) continue; + name = posn->symref ? posn->symref : posn->name; if (data->refspecs) - private = apply_refspecs(data->refspecs, data->refspec_nr, posn->name); + private = apply_refspecs(data->refspecs, data->refspec_nr, name); else - private = xstrdup(posn->name); + private = xstrdup(name); if (private) { read_ref(private, posn->old_sha1); free(private); |