From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: [PATCH 3/3] push: add remote.*.pushHeadOnly configuration Date: Tue, 14 Jul 2009 01:07:42 +0200 Message-ID: <1247526462-17584-4-git-send-email-bonzini@gnu.org> References: <1247526462-17584-1-git-send-email-bonzini@gnu.org> To: X-From: git-owner@vger.kernel.org Tue Jul 14 01:08:12 2009 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1MQUd1-0000nt-Lk for gcvg-git-2@gmane.org; Tue, 14 Jul 2009 01:08:12 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757600AbZGMXH5 (ORCPT ); Mon, 13 Jul 2009 19:07:57 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753773AbZGMXH4 (ORCPT ); Mon, 13 Jul 2009 19:07:56 -0400 Received: from fencepost.gnu.org ([140.186.70.10]:39444 "EHLO fencepost.gnu.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756643AbZGMXHx (ORCPT ); Mon, 13 Jul 2009 19:07:53 -0400 Received: from bonzini by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1MQUci-0007Un-RD for git@vger.kernel.org; Mon, 13 Jul 2009 19:07:53 -0400 X-Mailer: git-send-email 1.6.2.5 In-Reply-To: <1247526462-17584-1-git-send-email-bonzini@gnu.org> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: This patch adds a remote.*.pushHeadOnly configuration that automatically enables (when possible) the --current option to git push. Signed-off-by: Paolo Bonzini --- 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..uploadpack:: The default program to execute on the remote side when fetching. See option \--upload-pack of linkgit:git-fetch-pack[1]. +remote..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..tagopt:: Setting this value to \--no-tags disables automatic tag following when fetching from remote diff --git a/builtin-push.c b/builtin-push.c index 2911513..fcecd14 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -127,6 +127,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 bdc98ec..eee9e00 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.2.5