branch: factor out delete_branch_config()
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>
René Scharfe committed
Oct 18, 2012 at 14:04 UTC
22ed79275360a3dbb480e2c510a94c4b817afad2
1 file changed
+10
-5
builtin/branch.c
+10
-5
@@ -172,6 +172,15 @@ static int check_branch_commit(const char *branchname, const char *refname,
172
return 0;
173
}
174
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
+
184
static int delete_branches(int argc, const char **argv, int force, int kinds,
185
int quiet)
186
{
@@ -237,17 +246,13 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
246
bname.buf);
247
ret = 1;
248
} else {
240
- struct strbuf buf = STRBUF_INIT;
249
if (!quiet)
250
printf(remote_branch
251
? _("Deleted remote branch %s (was %s).\n")
252
: _("Deleted branch %s (was %s).\n"),
253
bname.buf,
254
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);
256
}
257
}
258