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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Steffen Prohaska
Date: Sunday, November 18, 2007 - 9:13 am

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, (Sun Oct 21, 11:32 pm)
Re: What's cooking in git/spearce.git (topics), Jeff King, (Sun Oct 21, 11:59 pm)
Re: What's cooking in git/spearce.git (topics), Jeff King, (Mon Oct 22, 12:16 am)
Re: What's cooking in git/spearce.git (topics), Pierre Habouzit, (Mon Oct 22, 12:24 am)
Re: What's cooking in git/spearce.git (topics), Steffen Prohaska, (Mon Oct 22, 8:27 am)
Re: What's cooking in git/spearce.git (topics), Junio C Hamano, (Mon Oct 22, 6:26 pm)
Re: What's cooking in git/spearce.git (topics), Linus Torvalds, (Mon Oct 22, 7:32 pm)
Re: What's cooking in git/spearce.git (topics), Shawn O. Pearce, (Mon Oct 22, 8:34 pm)
Re: What's cooking in git/spearce.git (topics), Jeff King, (Mon Oct 22, 8:48 pm)
What's cooking in git.git (topics), Junio C Hamano, (Wed Oct 24, 5:51 am)
Re: What's cooking in git.git (topics), David Symonds, (Wed Oct 24, 6:09 am)
Re: What's cooking in git.git (topics), Scott Parish, (Wed Oct 24, 9:08 am)
Re: What's cooking in git.git (topics), Andreas Ericsson, (Wed Oct 24, 11:27 am)
Re: What's cooking in git.git (topics), Scott Parish, (Wed Oct 24, 5:35 pm)
What's cooking in git.git (topics), Junio C Hamano, (Wed Oct 31, 10:41 pm)
Re: What's cooking in git.git (topics), Linus Torvalds, (Thu Nov 1, 11:33 am)
Re: What's cooking in git.git (topics), Geert Bosch, (Thu Nov 1, 12:19 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 1:27 pm)
Re: What's cooking in git.git (topics), Mike Hommey, (Thu Nov 1, 1:47 pm)
Re: What's cooking in git.git (topics), Geert Bosch, (Thu Nov 1, 2:17 pm)
Re: What's cooking in git.git (topics), Theodore Tso, (Thu Nov 1, 2:18 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 2:20 pm)
Re: What's cooking in git.git (topics), Melchior FRANZ, (Thu Nov 1, 2:26 pm)
Re: What's cooking in git.git (topics), Johan Herland, (Thu Nov 1, 2:32 pm)
Re: What's cooking in git.git (topics), Brian Downing, (Thu Nov 1, 2:41 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 2:42 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 2:44 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 2:46 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 2:51 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Thu Nov 1, 2:57 pm)
Re: What's cooking in git.git (topics), Linus Torvalds, (Thu Nov 1, 3:05 pm)
Re: What's cooking in git.git (topics), Bill Lear, (Thu Nov 1, 3:26 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 3:50 pm)
Re: What's cooking in git.git (topics), Jonas Fonseca, (Thu Nov 1, 5:00 pm)
Re: What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 1, 5:32 pm)
Re: What's cooking in git.git (topics), Petr Baudis, (Thu Nov 1, 7:19 pm)
Re: What's cooking in git.git (topics), Miles Bader, (Thu Nov 1, 11:06 pm)
Re: What's cooking in git.git (topics), Andreas Ericsson, (Fri Nov 2, 2:38 am)
Re: What's cooking in git.git (topics), Andreas Ericsson, (Fri Nov 2, 2:39 am)
Re: What's cooking in git.git (topics), Wincent Colaiuta, (Fri Nov 2, 3:26 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Fri Nov 2, 4:03 am)
Re: What's cooking in git.git (topics), Miles Bader, (Fri Nov 2, 8:13 am)
What's cooking in git.git (topics), Junio C Hamano, (Sat Nov 3, 9:14 pm)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Sun Nov 4, 4:38 am)
What's cooking in git.git (topics), Junio C Hamano, (Thu Nov 8, 1:08 am)
Re: What's cooking in git.git (topics), Steffen Prohaska, (Thu Nov 8, 1:44 pm)
What's cooking in git.git (topics), Junio C Hamano, (Mon Nov 12, 12:09 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Mon Nov 12, 5:21 am)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Mon Nov 12, 5:26 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Mon Nov 12, 5:33 am)
[PATCH] rebase: brown paper bag fix after the detached HEA ..., Johannes Schindelin, (Mon Nov 12, 6:11 am)
Re: What's cooking in git.git (topics), Steffen Prohaska, (Mon Nov 12, 7:27 am)
Re: What's cooking in git.git (topics), Pierre Habouzit, (Mon Nov 12, 7:53 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Mon Nov 12, 8:02 am)
What's cooking in git.git (topics), Junio C Hamano, (Wed Nov 14, 5:18 pm)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Wed Nov 14, 5:49 pm)
Re: What's cooking in git.git (topics), Jeff King, (Sat Nov 17, 5:40 am)
[PATCH 1/2] push: Add '--matching' option and print warnin ..., Steffen Prohaska, (Sun Nov 18, 9:13 am)
Re: [PATCH 2/2] push: Add '--current', which pushes only t ..., Steffen Prohaska, (Sun Nov 18, 11:41 pm)