builtin/clone.c: detect a clone starting at a tag correctly
authorJunio C Hamano <gitster@pobox.com>
Mon, 23 Jun 2014 21:27:36 +0000 (14:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Jun 2014 21:31:35 +0000 (14:31 -0700)
31b808a0 (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 <gitster@pobox.com>
builtin/clone.c
index 9b3c04d914b3d318f723c2d3ded403fca9503c07..545105a86fdf07873948f2bbe7d1c4f6e65b1509 100644 (file)
@@ -695,7 +695,7 @@ static void write_refspec_config(const char* src_ref_prefix,
        if (option_mirror || !option_bare) {
                if (option_single_branch && !option_mirror) {
                        if (option_branch) {
-                               if (strstr(our_head_points_at->name, "refs/tags/"))
+                               if (starts_with(our_head_points_at->name, "refs/tags/"))
                                        strbuf_addf(&value, "+%s:%s", our_head_points_at->name,
                                                our_head_points_at->name);
                                else