summaryrefslogtreecommitdiff
path: root/refspec.h
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2018-05-31 07:23:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-06-01 06:15:22 (GMT)
commit6c301adb0a43bceef65e78df6936bd03a4d1933b (patch)
tree7fca307edbf979aa7f3bd04c75cf8a040bd6faf0 /refspec.h
parentdcc73cf7ffd17e68bda05fff4c139465580aff28 (diff)
downloadgit-6c301adb0a43bceef65e78df6936bd03a4d1933b.zip
git-6c301adb0a43bceef65e78df6936bd03a4d1933b.tar.gz
git-6c301adb0a43bceef65e78df6936bd03a4d1933b.tar.bz2
fetch: do not pass ref-prefixes for fetch by exact SHA1
When v2.18.0-rc0~10^2~1 (refspec: consolidate ref-prefix generation logic, 2018-05-16) factored out the ref-prefix generation code for reuse, it left out the 'if (!item->exact_sha1)' test in the original ref-prefix generation code. As a result, fetches by SHA-1 generate ref-prefixes as though the SHA-1 being fetched were an abbreviated ref name: $ GIT_TRACE_PACKET=1 bin-wrappers/git -c protocol.version=2 \ fetch origin 12039e008f9a4e3394f3f94f8ea897785cb09448 [...] packet: fetch> ref-prefix 12039e008f9a4e3394f3f94f8ea897785cb09448 packet: fetch> ref-prefix refs/12039e008f9a4e3394f3f94f8ea897785cb09448 packet: fetch> ref-prefix refs/tags/12039e008f9a4e3394f3f94f8ea897785cb09448 packet: fetch> ref-prefix refs/heads/12039e008f9a4e3394f3f94f8ea897785cb09448 packet: fetch> ref-prefix refs/remotes/12039e008f9a4e3394f3f94f8ea897785cb09448 packet: fetch> ref-prefix refs/remotes/12039e008f9a4e3394f3f94f8ea897785cb09448/HEAD packet: fetch> 0000 If there is another ref name on the command line or the object being fetched is already available locally, then that's mostly harmless. But otherwise, we error out with fatal: no matching remote head since the server did not send any refs we are interested in. Filter out the exact_sha1 refspecs to avoid this. This patch adds a test to check this behavior that notices another behavior difference between protocol v0 and v2 in the process. Add a NEEDSWORK comment to clear it up. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refspec.h')
-rw-r--r--refspec.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/refspec.h b/refspec.h
index 01b700e..3a93638 100644
--- a/refspec.h
+++ b/refspec.h
@@ -42,6 +42,10 @@ void refspec_clear(struct refspec *rs);
int valid_fetch_refspec(const char *refspec);
struct argv_array;
+/*
+ * Determine what <prefix> values to pass to the peer in ref-prefix lines
+ * (see Documentation/technical/protocol-v2.txt).
+ */
void refspec_ref_prefixes(const struct refspec *rs,
struct argv_array *ref_prefixes);