OSDN Git Service

builtin remote rm: remove symbolic refs, too
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Sat, 8 Mar 2008 22:40:42 +0000 (23:40 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 9 Mar 2008 05:30:22 +0000 (21:30 -0800)
"git remote add" can add a symbolic ref "HEAD", and "rm" should delete
it, too.

Noticed by Teemu Likonen.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-remote.c
t/t5505-remote.sh

index ca3bf26..637b904 100644 (file)
@@ -264,6 +264,11 @@ static int add_branch_for_removal(const char *refname,
 
        if (!prefixcmp(refname, branches->prefix)) {
                struct path_list_item *item;
+
+               /* make sure that symrefs are deleted */
+               if (flags & REF_ISSYMREF)
+                       return unlink(git_path(refname));
+
                item = path_list_append(refname, branches->branches);
                item->util = xmalloc(20);
                hashcpy(item->util, sha1);
index f45ea68..2822a65 100755 (executable)
@@ -80,6 +80,7 @@ test_expect_success 'add another remote' '
 test_expect_success 'remove remote' '
 (
        cd test &&
+       git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
        git remote rm second
 )
 '