Skip to content

Commit 22ed792

Browse files
René Scharfegitster
authored andcommitted
branch: factor out delete_branch_config()
Provide a small helper function for deleting branch config sections. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f5d0e16 commit 22ed792

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

builtin/branch.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ static int check_branch_commit(const char *branchname, const char *refname,
172172
return 0;
173173
}
174174

175+
static void delete_branch_config(const char *branchname)
176+
{
177+
struct strbuf buf = STRBUF_INIT;
178+
strbuf_addf(&buf, "branch.%s", branchname);
179+
if (git_config_rename_section(buf.buf, NULL) < 0)
180+
warning(_("Update of config-file failed"));
181+
strbuf_release(&buf);
182+
}
183+
175184
static int delete_branches(int argc, const char **argv, int force, int kinds,
176185
int quiet)
177186
{
@@ -237,17 +246,13 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
237246
bname.buf);
238247
ret = 1;
239248
} else {
240-
struct strbuf buf = STRBUF_INIT;
241249
if (!quiet)
242250
printf(remote_branch
243251
? _("Deleted remote branch %s (was %s).\n")
244252
: _("Deleted branch %s (was %s).\n"),
245253
bname.buf,
246254
find_unique_abbrev(sha1, DEFAULT_ABBREV));
247-
strbuf_addf(&buf, "branch.%s", bname.buf);
248-
if (git_config_rename_section(buf.buf, NULL) < 0)
249-
warning(_("Update of config-file failed"));
250-
strbuf_release(&buf);
255+
delete_branch_config(bname.buf);
251256
}
252257
}
253258

0 commit comments

Comments
 (0)