Skip to content

Commit

Permalink
branch: factor out delete_branch_config()
Browse files Browse the repository at this point in the history
Provide a small helper function for deleting branch config sections.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Oct 18, 2012
1 parent f5d0e16 commit 22ed792
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions builtin/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ static int check_branch_commit(const char *branchname, const char *refname,
return 0;
}

static void delete_branch_config(const char *branchname)
{
struct strbuf buf = STRBUF_INIT;
strbuf_addf(&buf, "branch.%s", branchname);
if (git_config_rename_section(buf.buf, NULL) < 0)
warning(_("Update of config-file failed"));
strbuf_release(&buf);
}

static int delete_branches(int argc, const char **argv, int force, int kinds,
int quiet)
{
Expand Down Expand Up @@ -237,17 +246,13 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
bname.buf);
ret = 1;
} else {
struct strbuf buf = STRBUF_INIT;
if (!quiet)
printf(remote_branch
? _("Deleted remote branch %s (was %s).\n")
: _("Deleted branch %s (was %s).\n"),
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(bname.buf);
}
}

Expand Down

0 comments on commit 22ed792

Please sign in to comment.