builtin remote rm: remove symbolic refs, too

"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>
This commit is contained in:
Johannes Schindelin 2008-03-08 23:40:42 +01:00 committed by Junio C Hamano
parent 84521ed6f2
commit 3b9dcff5df
2 changed files with 6 additions and 0 deletions

View File

@ -264,6 +264,11 @@ static int add_branch_for_removal(const char *refname,
if (!prefixcmp(refname, branches->prefix)) { if (!prefixcmp(refname, branches->prefix)) {
struct path_list_item *item; 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 = path_list_append(refname, branches->branches);
item->util = xmalloc(20); item->util = xmalloc(20);
hashcpy(item->util, sha1); hashcpy(item->util, sha1);

View File

@ -80,6 +80,7 @@ test_expect_success 'add another remote' '
test_expect_success 'remove remote' ' test_expect_success 'remove remote' '
( (
cd test && cd test &&
git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
git remote rm second git remote rm second
) )
' '