git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <bonzini@gnu.org>
To: <git@vger.kernel.org>
Subject: [PATCH 5/6] move deletion of merge configuration to branch.c
Date: Sun, 12 Jul 2009 14:17:32 +0200	[thread overview]
Message-ID: <1247401053-20429-6-git-send-email-bonzini@gnu.org> (raw)
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

  parent reply	other threads:[~2009-07-12 12:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-12 12:17 [PATCH 0/6] Tracking setup improvements: per-remote config, autosetuppush Paolo Bonzini
2009-07-12 12:17 ` [PATCH 1/6] config: allow false and true values for branch.autosetuprebase Paolo Bonzini
2009-07-12 12:17 ` [PATCH 2/6] branch: install_branch_config and struct tracking refactoring Paolo Bonzini
2009-07-12 12:17 ` [PATCH 3/6] introduce a struct tracking_config Paolo Bonzini
2009-07-12 12:17 ` [PATCH 4/6] remote: add per-remote autosetupmerge and autosetuprebase configuration Paolo Bonzini
2009-07-12 12:17 ` Paolo Bonzini [this message]
2009-07-12 12:17 ` [PATCH 6/6] branch, checkout: introduce autosetuppush Paolo Bonzini
2009-07-12 21:17 ` [PATCH 0/6] Tracking setup improvements: per-remote config, autosetuppush Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1247401053-20429-6-git-send-email-bonzini@gnu.org \
    --to=bonzini@gnu.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).