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

[PATCH 5/6] move deletion of merge configuration to branch.c

From
Paolo Bonzini <bonzini@gnu.org>
Date
Jul 12, 2009, 12:17 UTC
Message-ID
<1247401053-20429-6-git-send-email-bonzini@gnu.org>
In-Reply-To
<1247401053-20429-1-git-send-email-bonzini@gnu.org>

In the next step, deletion of merge configuration will become more complex, so we move it into a separate function. Since the configuration is installed with a function in branch.c, I'm placing deletion there as well.

At the same time, the interface is changed to get the full ref name including refs/heads/. This makes no big difference for the caller.

Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
---
 branch.c         |   11 +++++++++++
 branch.h         |    2 ++
 builtin-branch.c |    6 +-----
 3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/branch.c b/branch.c
index e427721..8d3e8d8 100644
--- a/branch.c
+++ b/branch.c
@@ -85,6 +85,17 @@ void install_branch_config(int flag, const char *local, struct remote *remote,
 	strbuf_release(&key);
 }
 
+void delete_branch_config (const char *name)
+{
+	struct strbuf buf = STRBUF_INIT;
+	if (prefixcmp(name, "refs/heads/"))
+		return;
+	strbuf_addf(&buf, "branch.%s", name + 11);
+	if (git_config_rename_section(buf.buf, NULL) < 0)
+		warning("Update of config-file failed");
+	strbuf_release(&buf);
+}
+
 /*
  * This is called when new_ref is branched off of orig_ref, and tries
  * to infer the settings for branch.<new_ref>.{remote,merge} from the
diff --git a/branch.h b/branch.h
index f7c02c9..efa4506 100644
--- a/branch.h
+++ b/branch.h
@@ -21,6 +21,8 @@ void create_branch(const char *head, const char *name, const char *start_name,
  */
 void remove_branch_state(void);
 
+void delete_branch_config(const char *name);
+
 /*
  * Configure local branch "local" to merge remote branch "remote"
  * taken from origin "origin".
diff --git a/builtin-branch.c b/builtin-branch.c
index f045e16..4469ea9 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -166,14 +166,10 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 			      bname.buf);
 			ret = 1;
 		} else {
-			struct strbuf buf = STRBUF_INIT;
 			printf("Deleted %sbranch %s (was %s).\n", remote,
 			       bname.buf,
 			       find_unique_abbrev(sha1, DEFAULT_ABBREV));
-			strbuf_addf(&buf, "branch.%s", bname.buf);
-			if (git_config_rename_section(buf.buf, NULL) < 0)
-				warning("Update of config-file failed");
-			strbuf_release(&buf);
+			delete_branch_config (name);
 		}
 	}
 
-- 
1.6.2.5
Previous: Paolo BonziniNext: Paolo Bonzini
Message 6 of 8 in “Tracking setup improvements: per-remote config, autosetuppush”
  1. 0/6 Tracking setup improvements: per-remote config, autosetuppushPaolo Bonzini, Jul 12, 2009
  2. 1/6 config: allow false and true values for branch.autosetuprebasePaolo Bonzini, Jul 12, 2009
  3. 2/6 branch: install_branch_config and struct tracking refactoringPaolo Bonzini, Jul 12, 2009
  4. 3/6 introduce a struct tracking_configPaolo Bonzini, Jul 12, 2009
  5. 4/6 remote: add per-remote autosetupmerge and autosetuprebase configurationPaolo Bonzini, Jul 12, 2009
  6. 5/6 move deletion of merge configuration to branch.cPaolo Bonzini, Jul 12, 2009
  7. 6/6 branch, checkout: introduce autosetuppushPaolo Bonzini, Jul 12, 2009
  8. Junio C HamanoJul 12, 2009

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.