From 08e6b602bac273b218fbd441cea1915b5bb89a67 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sun, 12 Jul 2009 14:17:32 +0200 Subject: [PATCH] move deletion of merge configuration to branch.c 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 Signed-off-by: Junio C Hamano --- 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 e4277210c7..8d3e8d8b6a 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..{remote,merge} from the diff --git a/branch.h b/branch.h index f7c02c9083..efa4506d84 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 f045e16cb5..4469ea992e 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); } } -- 2.11.4.GIT