summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2014-04-20 14:45:05 -0500
committerJunio C Hamano <gitster@pobox.com>2014-04-21 11:46:17 -0700
commit0794b01bf8d99b6ac9284cfb92f82ac0243c23a4 (patch)
tree519517f3524f39e8c32c1f7f6b21b78a2ef9ad9a
parentd7c060252e016c8a9b7f38d1125c4ee281bb1b19 (diff)
downloadgit-0794b01bf8d99b6ac9284cfb92f82ac0243c23a4.tar.gz
sha1_name: simplify track finding
It's more efficient to check for the braces first. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--sha1_name.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 84d603a75a..45cfcfcab7 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -417,7 +417,7 @@ static int ambiguous_path(const char *path, int len)
static inline int upstream_mark(const char *string, int len)
{
- const char *suffix[] = { "@{upstream}", "@{u}" };
+ const char *suffix[] = { "upstream", "u" };
int i;
for (i = 0; i < ARRAY_SIZE(suffix); i++) {
@@ -475,7 +475,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
nth_prior = 1;
continue;
}
- if (!upstream_mark(str + at, len - at)) {
+ if (!upstream_mark(str + at + 2, len - at - 3)) {
reflog_len = (len-1) - (at+2);
len = at;
}
@@ -1091,7 +1091,10 @@ static int interpret_upstream_mark(const char *name, int namelen,
{
int len;
- len = upstream_mark(name + at, namelen - at);
+ if (name[at + 1] != '{' || name[namelen - 1] != '}')
+ return -1;
+
+ len = upstream_mark(name + at + 2, namelen - at - 3);
if (!len)
return -1;
@@ -1099,7 +1102,7 @@ static int interpret_upstream_mark(const char *name, int namelen,
return -1;
set_shortened_ref(buf, get_upstream_branch(name, at));
- return len + at;
+ return len + at + 3;
}
/*