git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Finn Arne Gangstad <finnag@pvv.org>
To: git@vger.kernel.org
Subject: [PATCH 2/7] New config option push.default
Date: Mon,  9 Mar 2009 23:35:46 +0100	[thread overview]
Message-ID: <1236638151-6465-3-git-send-email-finnag@pvv.org> (raw)
In-Reply-To: <1236638151-6465-1-git-send-email-finnag@pvv.org>

This option takes effect when no refspec is given explicitly or implicitly
by any of the command line arguments to push, and no refspec is configured
for the current remote. The possible values are:
* nothing - do not push anything
* current - push the current branch to whatever it is tracking
* matching - push all branches that already exist remotely (same name)

Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
---
 Documentation/config.txt |   18 ++++++++++++++++++
 cache.h                  |    8 ++++++++
 config.c                 |   23 +++++++++++++++++++++++
 environment.c            |    1 +
 4 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index f5152c5..50bc1d0 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1160,6 +1160,24 @@ pull.octopus::
 pull.twohead::
 	The default merge strategy to use when pulling a single branch.
 
+push.default::
+	Defines the action git push should take if no refspec is given
+	on the command line, no refspec is configured in the remote, and
+	no refspec is implied by any of the options given on the command
+	line.
+
+	The term `current remote` means the remote configured for the current
+	branch, or `origin` if no remote is configured. `origin` is also used
+	if you are not on any branch.
++
+* `nothing` do not push anything
+* `matching` push all matching branches to the current remote.
+  All branches having the same name in both ends are considered to be
+  matching. This is the default value.
+* `current` push the current branch to the branch it is tracking on
+  the remote
+
+
 receive.fsckObjects::
 	If it is set to true, git-receive-pack will check all received
 	objects. It will abort in the case of a malformed object or a
diff --git a/cache.h b/cache.h
index 189151d..3a6acb8 100644
--- a/cache.h
+++ b/cache.h
@@ -541,8 +541,16 @@ enum rebase_setup_type {
 	AUTOREBASE_ALWAYS,
 };
 
+enum push_default_type {
+	PUSH_DEFAULT_UNSPECIFIED = -1,
+	PUSH_DEFAULT_NOTHING = 0,
+	PUSH_DEFAULT_MATCHING,
+	PUSH_DEFAULT_CURRENT,
+};
+
 extern enum branch_track git_branch_track;
 extern enum rebase_setup_type autorebase;
+extern enum push_default_type push_default;
 
 #define GIT_REPO_VERSION 0
 extern int repository_format_version;
diff --git a/config.c b/config.c
index 0c8c76f..12d5a2b 100644
--- a/config.c
+++ b/config.c
@@ -565,6 +565,26 @@ static int git_default_branch_config(const char *var, const char *value)
 	return 0;
 }
 
+static int git_default_push_config(const char *var, const char *value)
+{
+	if (!strcmp(var, "push.default")) {
+		if (!value)
+			return config_error_nonbool(var);
+		else if (!strcmp(value, "nothing"))
+			push_default = PUSH_DEFAULT_NOTHING;
+		else if (!strcmp(value, "current"))
+			push_default = PUSH_DEFAULT_CURRENT;
+		else if (!strcmp(value, "matching"))
+			push_default = PUSH_DEFAULT_MATCHING;
+		else
+			return error("Malformed value for %s", var);
+		return 0;
+	}
+
+	/* Add other config variables here and to Documentation/config.txt. */
+	return 0;
+}
+
 static int git_default_mailmap_config(const char *var, const char *value)
 {
 	if (!strcmp(var, "mailmap.file"))
@@ -588,6 +608,9 @@ int git_default_config(const char *var, const char *value, void *dummy)
 	if (!prefixcmp(var, "branch."))
 		return git_default_branch_config(var, value);
 
+	if (!prefixcmp(var, "push."))
+		return git_default_push_config(var, value);
+
 	if (!prefixcmp(var, "mailmap."))
 		return git_default_mailmap_config(var, value);
 
diff --git a/environment.c b/environment.c
index e278bce..4696885 100644
--- a/environment.c
+++ b/environment.c
@@ -42,6 +42,7 @@ enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
 unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
 enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
+enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
 
 /* Parallel index stat data preload? */
 int core_preload_index = 0;
-- 
1.6.2.105.g6ff1f.dirty

  parent reply	other threads:[~2009-03-09 23:22 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-09 22:35 [RFC/PATCH] git push usability improvements and default change Finn Arne Gangstad
2009-03-09 22:35 ` [PATCH 1/7] remote: Make "-" an alias for the current remote Finn Arne Gangstad
2009-03-09 22:35 ` Finn Arne Gangstad [this message]
2009-03-09 22:35 ` [PATCH 3/7] git push: New options --matching and --current Finn Arne Gangstad
2009-03-09 23:49   ` Daniel Barkalow
2009-03-10  8:54     ` Finn Arne Gangstad
2009-03-09 22:35 ` [PATCH 4/7] git push: Display warning on unconfigured default push Finn Arne Gangstad
2009-03-10  0:25   ` Jay Soffian
2009-03-09 22:35 ` [PATCH 5/7] git push: Document that "nothing" is the future push default Finn Arne Gangstad
2009-03-09 22:35 ` [PATCH 6/7] git push: Change default for "git push" to nothing Finn Arne Gangstad
2009-03-09 22:35 ` [PATCH 7/7] git push: Remove warning for "git push" default change Finn Arne Gangstad
2009-03-09 23:35 ` [RFC/PATCH] git push usability improvements and " Johannes Schindelin
2009-03-10  0:12   ` Junio C Hamano
2009-03-10  8:46   ` Finn Arne Gangstad
2009-03-10 11:01     ` Johannes Schindelin
2009-03-10 11:12       ` Finn Arne Gangstad
2009-03-10  0:07 ` Junio C Hamano
2009-03-10  0:19   ` Junio C Hamano
2009-03-10 10:04   ` Finn Arne Gangstad
2009-03-10 16:20     ` Jay Soffian
2009-03-11 20:35     ` Junio C Hamano
2009-03-12  3:01       ` Nanako Shiraishi
2009-03-12 10:22         ` Finn Arne Gangstad
2009-03-12 10:52           ` Miles Bader
2009-03-12 12:20             ` Finn Arne Gangstad
2009-03-13  8:28               ` Miles Bader
2009-03-13 10:07                 ` John Tapsell
2009-03-10 17:52 ` Jeff King
2009-03-10 22:04   ` Finn Arne Gangstad
2009-03-10 22:10     ` Jeff King
2009-03-11  1:57     ` Jay Soffian

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=1236638151-6465-3-git-send-email-finnag@pvv.org \
    --to=finnag@pvv.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).