summaryrefslogtreecommitdiff
path: root/remote.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-03-20 23:34:37 -0700
committerJunio C Hamano <gitster@pobox.com>2008-03-22 23:46:17 -0700
commit46220ca100cfbcdd7d80a5ac3326c52a3e98dddb (patch)
tree1be191714a19aedb740a34e9ac838fe54f3cf34e /remote.h
parent9b33fa08b2d9507f8ffefe7649a59d23b4176185 (diff)
downloadgit-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 'remote.h')
-rw-r--r--remote.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/remote.h b/remote.h
index f1dedf15f6..7e9ae792dc 100644
--- a/remote.h
+++ b/remote.h
@@ -67,7 +67,8 @@ void free_refs(struct ref *ref);
*/
void ref_remove_duplicates(struct ref *ref_map);
-struct refspec *parse_ref_spec(int nr_refspec, const char **refspec);
+struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);
+struct refspec *parse_push_refspec(int nr_refspec, const char **refspec);
int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
int nr_refspec, const char **refspec, int all);