branch: show targets of deleted symrefs, not sha1s
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Thu, 18 Oct 2012 12:08:03 +0000 (14:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Oct 2012 21:36:17 +0000 (14:36 -0700)
git branch reports the abbreviated hash of the head commit of
a deleted branch to make it easier for a user to undo the
operation. For symref branches this doesn't help. Print the
symref target instead for them.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/branch.c
t/t3200-branch.sh
index d87035a2f457a40b32174a1173c414b042a3fbeb..1ec9c02612d0391984b484a5850f45c277a3e804 100644 (file)
@@ -251,15 +251,18 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                              : _("Error deleting branch '%s'"),
                              bname.buf);
                        ret = 1;
                              : _("Error deleting branch '%s'"),
                              bname.buf);
                        ret = 1;
-               } else {
-                       if (!quiet)
-                               printf(remote_branch
-                                      ? _("Deleted remote branch %s (was %s).\n")
-                                      : _("Deleted branch %s (was %s).\n"),
-                                      bname.buf,
-                                      find_unique_abbrev(sha1, DEFAULT_ABBREV));
-                       delete_branch_config(bname.buf);
+                       continue;
+               }
+               if (!quiet) {
+                       printf(remote_branch
+                              ? _("Deleted remote branch %s (was %s).\n")
+                              : _("Deleted branch %s (was %s).\n"),
+                              bname.buf,
+                              (flags & REF_ISSYMREF)
+                              ? target
+                              : find_unique_abbrev(sha1, DEFAULT_ABBREV));
                }
                }
+               delete_branch_config(bname.buf);
        }
 
        free(name);
        }
 
        free(name);
index 1323f6ff718d876ef06a071504390afa19a885a1..80e6be39d7b76d8e5daa6cad24a22a80a42e8eff 100755 (executable)
@@ -265,8 +265,7 @@ test_expect_success 'config information was renamed, too' \
 test_expect_success 'deleting a symref' '
        git branch target &&
        git symbolic-ref refs/heads/symref refs/heads/target &&
 test_expect_success 'deleting a symref' '
        git branch target &&
        git symbolic-ref refs/heads/symref refs/heads/target &&
-       sha1=$(git rev-parse symref | cut -c 1-7) &&
-       echo "Deleted branch symref (was $sha1)." >expect &&
+       echo "Deleted branch symref (was refs/heads/target)." >expect &&
        git branch -d symref >actual &&
        test_path_is_file .git/refs/heads/target &&
        test_path_is_missing .git/refs/heads/symref &&
        git branch -d symref >actual &&
        test_path_is_file .git/refs/heads/target &&
        test_path_is_missing .git/refs/heads/symref &&
@@ -276,7 +275,7 @@ test_expect_success 'deleting a symref' '
 test_expect_success 'deleting a dangling symref' '
        git symbolic-ref refs/heads/dangling-symref nowhere &&
        test_path_is_file .git/refs/heads/dangling-symref &&
 test_expect_success 'deleting a dangling symref' '
        git symbolic-ref refs/heads/dangling-symref nowhere &&
        test_path_is_file .git/refs/heads/dangling-symref &&
-       echo "Deleted branch dangling-symref (was 0000000)." >expect &&
+       echo "Deleted branch dangling-symref (was nowhere)." >expect &&
        git branch -d dangling-symref >actual &&
        test_path_is_missing .git/refs/heads/dangling-symref &&
        test_i18ncmp expect actual
        git branch -d dangling-symref >actual &&
        test_path_is_missing .git/refs/heads/dangling-symref &&
        test_i18ncmp expect actual