All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <bonzini@gnu.org>
To: <git@vger.kernel.org>
Cc: gitster@pobox.com
Subject: [PATCH 3/3] push: add remote.*.pushHeadOnly configuration
Date: Mon, 20 Jul 2009 13:58:14 +0200	[thread overview]
Message-ID: <1248091094-31485-4-git-send-email-bonzini@gnu.org> (raw)
In-Reply-To: <1248091094-31485-1-git-send-email-bonzini@gnu.org>

This patch adds a remote.*.pushHeadOnly configuration that automatically
enables (when possible) the --current option to git push.

Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
---
 Documentation/config.txt |    6 ++++++
 builtin-push.c           |    2 ++
 remote.c                 |    2 ++
 remote.h                 |    1 +
 t/t5516-fetch-push.sh    |   16 +++++++++++++++-
 5 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index cb6832b..4ab5593 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1359,6 +1359,12 @@ remote.<name>.uploadpack::
 	The default program to execute on the remote side when fetching.  See
 	option \--upload-pack of linkgit:git-fetch-pack[1].
 
+remote.<name>.pushHeadOnly::
+	If true, whenever `git push` is invoked without a refspec and
+	it will try pushing to this remote, `git push` will automatically
+	behave as if the `\--current` option was given on the command line.
+	In other words, only the current branch is pushed to the remote.
+
 remote.<name>.tagopt::
 	Setting this value to \--no-tags disables automatic tag following when
 	fetching from remote <name>
diff --git a/builtin-push.c b/builtin-push.c
index 71d94a5..8d5b054 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -109,6 +109,8 @@ static int do_push(const char *repo, int flags)
 
 	if (remote->mirror)
 		flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
+	if (remote->push_head_only && !refspec_nr)
+		flags |= TRANSPORT_PUSH_CURRENT;
 
 	if ((flags & TRANSPORT_PUSH_ALL) && refspec) {
 		if (!strcmp(*refspec, "refs/tags/*"))
diff --git a/remote.c b/remote.c
index b5bf9a6..d46dc0d 100644
--- a/remote.c
+++ b/remote.c
@@ -379,6 +379,8 @@ static int handle_config(const char *key, const char *value, void *cb)
 		remote->mirror = git_config_bool(key, value);
 	else if (!strcmp(subkey, ".skipdefaultupdate"))
 		remote->skip_default_update = git_config_bool(key, value);
+	else if (!strcmp(subkey, ".pushheadonly"))
+		remote->push_head_only = git_config_bool(key, value);
 
 	else if (!strcmp(subkey, ".url")) {
 		const char *v;
diff --git a/remote.h b/remote.h
index 8e5d5b4..b1e3e99 100644
--- a/remote.h
+++ b/remote.h
@@ -36,6 +36,7 @@ struct remote {
 	 * 2 to always fetch tags
 	 */
 	int fetch_tags;
+	int push_head_only;
 	int skip_default_update;
 	int mirror;
 
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index a480cb2..9d61ba0 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -631,9 +631,23 @@ test_expect_success 'push --current respects configuration' '
 	git config remote.bremote.push refs/heads/master:refs/heads/master2 &&
 	git push --current bremote &&
 	test $(git rev-parse master) = $(cd b.git && git rev-parse master2)
+'
+
+test_expect_success 'remote.*.pushHeadOnly respects configuration' '
+	echo xx > b &&
+	git commit -mmaster3 b &&
+	git config remote.bremote.pushHeadOnly true &&
 	git checkout branch &&
-	git push --current bremote 2>&1 | grep "Everything up-to-date" &&
+	git push bremote &&
+	test $(git rev-parse master^) = $(cd b.git && git rev-parse master) &&
 	test $(git rev-parse branch^) = $(cd b.git && git rev-parse branch)
 '
 
+test_expect_success 'remote.*.pushHeadOnly works' '
+	git config --unset remote.bremote.push &&
+	git push bremote &&
+	test $(git rev-parse master^) = $(cd b.git && git rev-parse master) &&
+	test $(git rev-parse branch) = $(cd b.git && git rev-parse branch)
+'
+
 test_done
-- 
1.6.4.rc1.10.g26dbf.dirty

  parent reply	other threads:[~2009-07-20 11:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-20 11:58 [PATCH v3 0/3] add push --current and remote.*.pushHeadOnly Paolo Bonzini
2009-07-20 11:58 ` [PATCH 1/3] reintroduce PUSH_DEFAULT_UNSPECIFIED Paolo Bonzini
2009-07-20 11:58 ` [PATCH 2/3] push: add --current Paolo Bonzini
2009-07-20 11:58 ` Paolo Bonzini [this message]
2009-07-20 20:38 ` [PATCH v3 0/3] add push --current and remote.*.pushHeadOnly Junio C Hamano
2009-07-20 22:09   ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2009-07-20  6:36 [PATCH " Paolo Bonzini
2009-07-20  6:37 ` [PATCH 3/3] push: add remote.*.pushHeadOnly configuration Paolo Bonzini
2009-07-13 23:07 [PATCH 0/3]: add git push --current and remote.*.pushHeadOnly Paolo Bonzini
2009-07-13 23:07 ` [PATCH 3/3] push: add remote.*.pushHeadOnly configuration Paolo Bonzini

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=1248091094-31485-4-git-send-email-bonzini@gnu.org \
    --to=bonzini@gnu.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.