login
Header Space

 
 

[PATCH 1/2] push: Add '--matching' option and print warning if it should be used

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Cc: Junio C Hamano <gitster@...>, Johannes Schindelin <Johannes.Schindelin@...>, Steffen Prohaska <prohaska@...>
Date: Sunday, November 18, 2007 - 12:13 pm

This on the road to
1) "git push --matching" pushes matching branches.
2) "git push --current" pushes only current branch.
3) "git push" reports error if the config does not contain a Push line.
   (after it reported a warning for a while).

Maybe in two years (that's twice an eternity in git time scales):

4) make "git push --current" the default.

This commit adds '--matching', which is a no-op at this point.
If appropriate, a warning is printed to tell the user that the
default will change in the future.

Thanks to Dscho for suggesting this.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 Documentation/git-push.txt |    8 +++++++-
 builtin-push.c             |   13 +++++++++++--
 t/t5516-fetch-push.sh      |   13 +++++++++++++
 3 files changed, 31 insertions(+), 3 deletions(-)

So here is '--matching'. And PATCH 2/2 will bring '--current'.
They apply on top of sp/refspec-match.

    Steffen

diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 4a68aab..d2417f3 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -9,7 +9,7 @@ git-push - Update remote refs along with associated objects
 SYNOPSIS
 --------
 [verse]
-'git-push' [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>]
+'git-push' [--all] [--matching] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>]
            [--repo=all] [-f | --force] [-v | --verbose] [<repository> <refspec>...]
 
 DESCRIPTION
@@ -63,6 +63,12 @@ the remote repository.
 	Instead of naming each ref to push, specifies that all
 	refs under `$GIT_DIR/refs/heads/` be pushed.
 
+\--matching::
+	Instead of naming each ref to push, specifies that matching
+	refs under `$GIT_DIR/refs/heads/` be pushed.  Matching means
+	the branch exists locally and at the remote under the same name.
+	Currently, this is the default.  But this will change in the future.
+
 \--dry-run::
 	Do everything except actually send the updates.
 
diff --git a/builtin-push.c b/builtin-push.c
index 54fba0e..7e9dcf1 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -10,7 +10,7 @@
 #include "parse-options.h"
 
 static const char * const push_usage[] = {
-	"git-push [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
+	"git-push [--all] [--matching] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
 	NULL,
 };
 
@@ -100,6 +100,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 {
 	int flags = 0;
 	int all = 0;
+	int matching = 0;
 	int dry_run = 0;
 	int force = 0;
 	int tags = 0;
@@ -109,6 +110,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 		OPT__VERBOSE(&verbose),
 		OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
 		OPT_BOOLEAN( 0 , "all", &all, "push all refs"),
+		OPT_BOOLEAN( 0 , "matching", &matching, "push matching refs"),
 		OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
 		OPT_BOOLEAN( 0 , "dry-run", &dry_run, "dry run"),
 		OPT_BOOLEAN('f', "force", &force, "force updates"),
@@ -135,8 +137,15 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 		repo = argv[0];
 		set_refspecs(argv + 1, argc - 1);
 	}
-	if ((flags & TRANSPORT_PUSH_ALL) && refspec)
+	if ((all != 0) + (matching != 0) > 1) {
+		fprintf(stderr, "--all and --matching are mutual exclusive.\n");
 		usage_with_options(push_usage, options);
+	}
+	if ((all || matching) && refspec)
+		usage_with_options(push_usage, options);
+	if (!all && !matching && !refspec)
+		fprintf(stderr, "Warning: assuming '--matching'."
+		                " This default will change in the future.\n");
 
 	return do_push(repo, flags);
 }
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index fd5f284..21aa7c3 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -100,6 +100,19 @@ test_expect_success 'fetch with wildcard' '
 	)
 '
 
+test_expect_code 129 'push command line options (1)' '
+	git push --all --matching testrepo
+'
+
+test_expect_code 129 'push command line options (2)' '
+	git push --matching testrepo master
+'
+
+test_expect_success 'push command line options (3)' '
+	git push testrepo 2>stderr.txt &&
+	grep -q "Warning: assuming.*--matching" stderr.txt
+'
+
 test_expect_success 'push without wildcard' '
 	mk_empty &&
 
-- 
1.5.3.5.743.g87c5c

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
What's cooking in git/spearce.git (topics), Shawn O. Pearce, (Mon Oct 22, 2:32 am)
What's cooking in git.git (topics), Junio C Hamano, (Wed Oct 24, 8:51 am)
What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 1:41 am)
What's cooking in git.git (topics), Junio C Hamano, (Sun Nov 4, 12:14 am)
What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 8, 4:08 am)
What's cooking in git.git (topics), Junio C Hamano, (Mon Nov 12, 3:09 am)
What's cooking in git.git (topics), Junio C Hamano, (Wed Nov 14, 8:18 pm)
Re: What's cooking in git.git (topics), Jeff King, (Sat Nov 17, 8:40 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Wed Nov 14, 8:49 pm)
[PATCH] t7501-commit: Add test for git commit &lt;file&gt; w..., Kristian Høgsberg, (Thu Nov 15, 10:49 am)
[PATCH] builtin-commit: fix "git add x y &amp;&amp; git comm..., Johannes Schindelin, (Thu Nov 15, 12:11 pm)
Re: [PATCH] builtin-commit: fix "git add x y &amp;&amp; git ..., Johannes Schindelin, (Thu Nov 15, 8:43 pm)
Re: [PATCH] builtin-commit: fix "git add x y &amp;&amp; git ..., Johannes Schindelin, (Thu Nov 15, 12:37 pm)
Re: [PATCH] t7501-commit: Add test for git commit &lt;file&g..., Johannes Schindelin, (Thu Nov 15, 11:55 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Mon Nov 12, 8:21 am)
Re: What's cooking in git.git (topics), Steffen Prohaska, (Mon Nov 12, 10:27 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Mon Nov 12, 11:02 am)
[PATCH 1/2] push: Add '--matching' option and print warning ..., Steffen Prohaska, (Sun Nov 18, 12:13 pm)
[PATCH 2/2] push: Add '--current', which pushes only the cur..., Steffen Prohaska, (Sun Nov 18, 12:13 pm)
[PATCH] push: Add "--current", which pushes only the current..., Steffen Prohaska, (Mon Nov 19, 12:51 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Mon Nov 12, 8:26 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Mon Nov 12, 8:33 am)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Mon Nov 12, 10:53 am)
[PATCH] rebase: brown paper bag fix after the detached HEAD ..., Johannes Schindelin, (Mon Nov 12, 9:11 am)
Re: What's cooking in git.git (topics), Steffen Prohaska, (Thu Nov 8, 4:44 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Sun Nov 4, 7:38 am)
Re: What's cooking in git.git (topics), Brian Downing, (Thu Nov 1, 5:41 pm)
Re: What's cooking in git.git (topics), Wincent Colaiuta, (Fri Nov 2, 6:26 am)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 5:46 pm)
Re: What's cooking in git.git (topics), Linus Torvalds, (Thu Nov 1, 2:33 pm)
Re: What's cooking in git.git (topics), Andreas Ericsson, (Fri Nov 2, 5:38 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Fri Nov 2, 7:03 am)
Re: What's cooking in git.git (topics), Miles Bader, (Fri Nov 2, 2:06 am)
Re: What's cooking in git.git (topics), Miles Bader, (Fri Nov 2, 11:13 am)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 5:57 pm)
Re: What's cooking in git.git (topics), Geert Bosch, (Thu Nov 1, 3:19 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 4:27 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 5:42 pm)
Re: What's cooking in git.git (topics), Andreas Ericsson, (Fri Nov 2, 5:39 am)
Re: What's cooking in git.git (topics), Johan Herland, (Thu Nov 1, 5:32 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 5:51 pm)
Re: What's cooking in git.git (topics), Linus Torvalds, (Thu Nov 1, 6:05 pm)
Re: What's cooking in git.git (topics), Petr Baudis, (Thu Nov 1, 10:19 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 6:50 pm)
Re: What's cooking in git.git (topics), Bill Lear, (Thu Nov 1, 6:26 pm)
Re: What's cooking in git.git (topics), Theodore Tso, (Thu Nov 1, 5:18 pm)
Re: What's cooking in git.git (topics), Melchior FRANZ, (Thu Nov 1, 5:26 pm)
Re: What's cooking in git.git (topics), Geert Bosch, (Thu Nov 1, 5:17 pm)
Re: What's cooking in git.git (topics), Jonas Fonseca, (Thu Nov 1, 8:00 pm)
Re: What's cooking in git.git (topics), Mike Hommey, (Thu Nov 1, 4:47 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 5:44 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 5:20 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 8:32 pm)
Re: What's cooking in git.git (topics), Scott Parish, (Wed Oct 24, 12:08 pm)
Re: What's cooking in git.git (topics), Andreas Ericsson, (Wed Oct 24, 2:27 pm)
Re: What's cooking in git.git (topics), Scott Parish, (Wed Oct 24, 8:35 pm)
Re: What's cooking in git.git (topics), David Symonds, (Wed Oct 24, 9:09 am)
Re: What's cooking in git/spearce.git (topics), Junio C Hamano, (Mon Oct 22, 9:26 pm)
Re: What's cooking in git/spearce.git (topics), Shawn O. Pearce, (Mon Oct 22, 11:34 pm)
Re: What's cooking in git/spearce.git (topics), Steffen Prohaska, (Mon Oct 22, 11:27 am)
Re: What's cooking in git/spearce.git (topics), Pierre Habouzit, (Mon Oct 22, 3:24 am)
Re: What's cooking in git/spearce.git (topics), Jeff King, (Mon Oct 22, 3:16 am)
Re: What's cooking in git/spearce.git (topics), Linus Torvalds, (Mon Oct 22, 10:32 pm)
Re: What's cooking in git/spearce.git (topics), Jeff King, (Mon Oct 22, 11:48 pm)
Re: What's cooking in git/spearce.git (topics), Jeff King, (Mon Oct 22, 2:59 am)
speck-geostationary