Skip to content

Commit 60a5f5f

Browse files
committed
builtin/clone.c: detect a clone starting at a tag correctly
31b808a (clone --single: limit the fetch refspec to fetched branch, 2012-09-20) tried to see if the given "branch" to follow is actually a tag at the remote repository by checking with "refs/tags/" but it incorrectly used strstr(3); it is actively wrong to treat a "branch" "refs/heads/refs/tags/foo" and use the logic for the "refs/tags/" ref hierarchy. What the code really wanted to do is to see if it starts with "refs/tags/". Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34d5217 commit 60a5f5f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ static void write_refspec_config(const char* src_ref_prefix,
695695
if (option_mirror || !option_bare) {
696696
if (option_single_branch && !option_mirror) {
697697
if (option_branch) {
698-
if (strstr(our_head_points_at->name, "refs/tags/"))
698+
if (starts_with(our_head_points_at->name, "refs/tags/"))
699699
strbuf_addf(&value, "+%s:%s", our_head_points_at->name,
700700
our_head_points_at->name);
701701
else

0 commit comments

Comments
 (0)