[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