Thread (7 messages) 7 messages, 2 authors, 2016-06-15

[PATCH 2/5] branch: factor out delete_branch_config()

flat view
DORMANTno replies

From: René Scharfe <hidden>
Date: 2016-06-15 22:55:04
Subsystem: the rest · Maintainer: Linus Torvalds

Provide a small helper function for deleting branch config sections.

Signed-off-by: Rene Scharfe <redacted>
---
 builtin/branch.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 852019e..97c7361 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -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)
 {
@@ -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);
 		}
 	}
 
-- 
1.7.12
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help