diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-03-20 23:34:37 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-03-22 23:46:17 -0700 |
commit | 46220ca100cfbcdd7d80a5ac3326c52a3e98dddb (patch) | |
tree | 1be191714a19aedb740a34e9ac838fe54f3cf34e /builtin-fetch.c | |
parent | 9b33fa08b2d9507f8ffefe7649a59d23b4176185 (diff) | |
download | git-46220ca100cfbcdd7d80a5ac3326c52a3e98dddb.tar.gz |
remote.c: Fix overtight refspec validation
We tightened the refspec validation code in an earlier commit ef00d15
(Tighten refspec processing, 2008-03-17) per my suggestion, but the
suggestion was misguided to begin with and it broke this usage:
$ git push origin HEAD~12:master
The syntax of push refspecs and fetch refspecs are similar in that they
are both colon separated LHS and RHS (possibly prefixed with a + to
force), but the similarity ends there. For example, LHS in a push refspec
can be anything that evaluates to a valid object name at runtime (except
when colon and RHS is missing, or it is a glob), while it must be a
valid-looking refname in a fetch refspec. To validate them correctly, the
caller needs to be able to say which kind of refspecs they are. It is
unreasonable to keep a single interface that cannot tell which kind it is
dealing with, and ask it to behave sensibly.
This commit separates the parsing of the two into different functions, and
clarifies the code to implement the parsing proper (i.e. splitting into
two parts, making sure both sides are wildcard or neither side is).
This happens to also allow pushing a commit named with the esoteric "look
for that string" syntax:
$ git push ../test.git ':/remote.c: Fix overtight refspec:master'
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-fetch.c')
-rw-r--r-- | builtin-fetch.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c index b2b9935ed6..a11548c894 100644 --- a/builtin-fetch.c +++ b/builtin-fetch.c @@ -652,5 +652,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) signal(SIGINT, unlock_pack_on_signal); atexit(unlock_pack); - return do_fetch(transport, parse_ref_spec(ref_nr, refs), ref_nr); + return do_fetch(transport, + parse_fetch_refspec(ref_nr, refs), ref_nr); } |