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 <gits...@pobox.com>

  Jeff King <p...@peff.net> writes:

  >> Because the pattern is not anchored to the left with a slash, it is
  >> clear that the original cannot even claim that it was trying to
  >> munge "foo/refs/tags/" as well.
  > Yeah, the strstr seems very wrong there. Even with the "/", why would
  > you want to match "refs/heads/refs/tags/"?
  >> Which means this is trivially correct, but at the same time I wonder
  >> what it means for our-head to point at a ref in refs/tags/ hierarchy.
  > I think it is for "git clone --branch=v1.0". We create a refspec pulling
  > v1.0 to its local tag in that case (as opposed to to something in
  > "refs/remotes/origin/").  So I really think this does want to be
  > starts_with.

  Thanks; here is what I'm gonna queue.

 builtin/clone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 9b3c04d..545105a 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -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, 
+                               if (starts_with(our_head_points_at->name, 
                                        strbuf_addf(&value, "+%s:%s", 

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to