diff --git a/sha1_name.c b/sha1_name.c index afdff2f1d5..26a5811c84 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -1095,6 +1095,9 @@ static int interpret_upstream_mark(const char *name, int namelen, if (!len) return -1; + if (memchr(name, ':', at)) + return -1; + set_shortened_ref(buf, get_upstream_branch(name, at)); return len + at; } diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh index 2a19e797eb..cace1ca4ad 100755 --- a/t/t1507-rev-parse-upstream.sh +++ b/t/t1507-rev-parse-upstream.sh @@ -210,4 +210,20 @@ test_expect_success 'log -g other@{u}@{now}' ' test_cmp expect actual ' +test_expect_success '@{reflog}-parsing does not look beyond colon' ' + echo content >@{yesterday} && + git add @{yesterday} && + git commit -m "funny reflog file" && + git hash-object @{yesterday} >expect && + git rev-parse HEAD:@{yesterday} >actual +' + +test_expect_success '@{upstream}-parsing does not look beyond colon' ' + echo content >@{upstream} && + git add @{upstream} && + git commit -m "funny upstream file" && + git hash-object @{upstream} >expect && + git rev-parse HEAD:@{upstream} >actual +' + test_done