Fix incorrect ref namespace check
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Thu, 5 Jan 2012 12:39:40 +0000 (19:39 +0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Jan 2012 20:52:12 +0000 (12:52 -0800)
The reason why the trailing slash is needed is obvious. refs/stash and
HEAD are not namespace, but complete refs. Do full string compare on them.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
builtin/remote.c
log-tree.c

index 8761a33b491ae8a9437d78247ef0808c0686486e..ea45cb0e8ed2b1b27ed709182ea9bcd271c91dae 100644 (file)
@@ -574,7 +574,7 @@ static void find_non_local_tags(struct transport *transport,
 
        for_each_ref(add_existing, &existing_refs);
        for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
-               if (prefixcmp(ref->name, "refs/tags"))
+               if (prefixcmp(ref->name, "refs/tags/"))
                        continue;
 
                /*
index c810643815e38f4ada805e2af49973e4e0051801..164626b1d1a82a4b01c2c5ea58e7ac3ed49a8c17 100644 (file)
@@ -535,7 +535,7 @@ static int add_branch_for_removal(const char *refname,
        }
 
        /* don't delete non-remote-tracking refs */
-       if (prefixcmp(refname, "refs/remotes")) {
+       if (prefixcmp(refname, "refs/remotes/")) {
                /* advise user how to delete local branches */
                if (!prefixcmp(refname, "refs/heads/"))
                        string_list_append(branches->skipped,
index e7694a3a4ca2e6de7fe8f3b5458eb2b65591373a..21ac9047c0a9fd635e2257792eef64b6e580da27 100644 (file)
@@ -119,9 +119,9 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
                type = DECORATION_REF_REMOTE;
        else if (!prefixcmp(refname, "refs/tags/"))
                type = DECORATION_REF_TAG;
-       else if (!prefixcmp(refname, "refs/stash"))
+       else if (!strcmp(refname, "refs/stash"))
                type = DECORATION_REF_STASH;
-       else if (!prefixcmp(refname, "HEAD"))
+       else if (!strcmp(refname, "HEAD"))
                type = DECORATION_REF_HEAD;
 
        if (!cb_data || *(int *)cb_data == DECORATE_SHORT_REFS)