git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-branch: cleanup config file when deleting branches

From
Gerrit Pape <pape@smarden.org>
Date
Jun 6, 2007, 10:09 UTC
Message-ID
<20070606100947.18990.qmail@bef1f6489d171f.315fe32.mid.smarden.org>

When deleting branches, remove the sections referring to these branches from the config file.

Signed-off-by: Gerrit Pape <pape@smarden.org>
---
 builtin-branch.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index a5b6bbe..3a70a7d 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)
-- 
1.5.2
Next: Junio C Hamano
Message 1 of 3 in “git-branch: cleanup config file when deleting branches”
  1. git-branch: cleanup config file when deleting branchesGerrit Pape, Jun 6, 2007
  2. Junio C HamanoJun 8, 2007
  3. git-branch: cleanup config file when deleting branchesGerrit Pape, Jun 9, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.