From f1eccbab638df66a7d8ec881f6f695514b26f44f Mon Sep 17 00:00:00 2001 From: Gerrit Pape Date: Sat, 9 Jun 2007 12:40:35 +0000 Subject: [PATCH] git-branch: cleanup config file when deleting branches When deleting branches, remove the sections referring to these branches from the config file. Signed-off-by: Gerrit Pape --- builtin-branch.c | 9 +++++++-- t/t3200-branch.sh | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/builtin-branch.c b/builtin-branch.c index da480519d7..bd4748f845 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -85,6 +85,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds) unsigned char sha1[20]; char *name = NULL; const char *fmt, *remote; + char section[PATH_MAX]; int i; int ret = 0; @@ -152,9 +153,13 @@ static int delete_branches(int argc, const char **argv, int force, int kinds) error("Error deleting %sbranch '%s'", remote, argv[i]); ret = 1; - } else + } else { printf("Deleted %sbranch %s.\n", remote, argv[i]); - + snprintf(section, sizeof(section), "branch.%s", + argv[i]); + if (git_config_rename_section(section, NULL) < 0) + warning("Update of config-file failed"); + } } if (name) diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 6f6d8844e8..f1793d0b9a 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -171,6 +171,15 @@ test_expect_success 'test tracking setup via --track but deeper' \ test "$(git-config branch.my7.remote)" = local && test "$(git-config branch.my7.merge)" = refs/heads/o/o' +test_expect_success 'test deleting branch deletes branch config' \ + 'git-branch -d my7 && + test "$(git-config branch.my7.remote)" = "" && + test "$(git-config branch.my7.merge)" = ""' + +test_expect_success 'test deleting branch without config' \ + 'git-branch my7 s && + test "$(git-branch -d my7 2>&1)" = "Deleted branch my7."' + # Keep this test last, as it changes the current branch cat >expect < 1117150200 +0000 branch: Created from master -- 2.11.4.GIT