git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 3/3] remote: introduce and fill branch->pushremote
Date: Sun, 12 Jan 2014 22:41:06 +0530	[thread overview]
Message-ID: <1389546666-17438-4-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1389546666-17438-1-git-send-email-artagnon@gmail.com>

When a caller uses branch_get() to retrieve a "struct branch", they get
the per-branch remote name and a pointer to the remote struct. However,
they have no way of knowing about the per-branch pushremote from this
interface. So, let's expose that information via fields similar to
"remote" and "remote_name"; "pushremote" and "pushremote_name".

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 remote.c | 15 ++++++++++++---
 remote.h |  3 +++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/remote.c b/remote.c
index a89efab..286cdce 100644
--- a/remote.c
+++ b/remote.c
@@ -351,9 +351,10 @@ static int handle_config(const char *key, const char *value, void *cb)
 				explicit_default_remote_name = 1;
 			}
 		} else if (!strcmp(subkey, ".pushremote")) {
+			if (git_config_string(&branch->pushremote_name, key, value))
+				return -1;
 			if (branch == current_branch)
-				if (git_config_string(&pushremote_name, key, value))
-					return -1;
+				pushremote_name = branch->pushremote_name;
 		} else if (!strcmp(subkey, ".merge")) {
 			if (!value)
 				return config_error_nonbool(key);
@@ -1543,7 +1544,9 @@ struct branch *branch_get(const char *name)
 		ret = current_branch;
 	else
 		ret = make_branch(name, 0);
-	if (ret && ret->remote_name) {
+	if (!ret)
+		return ret;
+	if (ret->remote_name) {
 		ret->remote = remote_get(ret->remote_name);
 		if (ret->merge_nr) {
 			int i;
@@ -1557,6 +1560,12 @@ struct branch *branch_get(const char *name)
 			}
 		}
 	}
+	if (ret->pushremote_name)
+		ret->pushremote = remote_get(ret->pushremote_name);
+	else if (pushremote_name)
+		ret->pushremote = remote_get(pushremote_name);
+	else
+		ret->pushremote = ret->remote;
 	return ret;
 }
 
diff --git a/remote.h b/remote.h
index 00c6a76..ac5aadc 100644
--- a/remote.h
+++ b/remote.h
@@ -201,6 +201,9 @@ struct branch {
 	const char *remote_name;
 	struct remote *remote;
 
+	const char *pushremote_name;
+	struct remote *pushremote;
+
 	const char **merge_name;
 	struct refspec **merge;
 	int merge_nr;
-- 
1.8.5.2.313.g5abf4c0.dirty

  parent reply	other threads:[~2014-01-12 17:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-12 17:11 [PATCH 0/3] Minor preparation for @{publish} Ramkumar Ramachandra
2014-01-12 17:11 ` [PATCH 1/3] t1507 (rev-parse-upstream): fix typo in test title Ramkumar Ramachandra
2014-01-12 17:11 ` [PATCH 2/3] interpret_branch_name: factor out upstream handling Ramkumar Ramachandra
2014-01-12 17:11 ` Ramkumar Ramachandra [this message]
2014-01-13  8:34   ` [PATCH 3/3] remote: introduce and fill branch->pushremote Jeff King
2014-01-13 11:22     ` Ramkumar Ramachandra
2014-01-13 18:59       ` Jeff King
2014-01-13 20:15         ` Junio C Hamano
2014-01-13 20:27           ` Jeff King

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=1389546666-17438-4-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /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).