summaryrefslogtreecommitdiff
path: root/builtin-push.c
diff options
context:
space:
mode:
authorBrian Ewins <brian.ewins@gmail.com>2007-10-11 20:32:27 +0100
committerShawn O. Pearce <spearce@spearce.org>2007-10-15 22:02:52 -0400
commit11f2441f05ace25f1dae833a804761f1ca7d5cbb (patch)
tree043837d89e777bda9414b469c5be5cf812dc38f7 /builtin-push.c
parenta63103ae4f02f8890d381de352dbfc6cba0b646f (diff)
downloadgit-11f2441f05ace25f1dae833a804761f1ca7d5cbb.tar.gz
Add a --dry-run option to git-push.
The default behaviour of git-push is potentially confusing for new users, since it will push changes that are not on the current branch. Publishing patches that were still cooking on a development branch is hard to undo. It would also be nice to be able to verify the expansion of refspecs if you've edited them, so that you know what branches matched on the server. Adding a --dry-run flag allows the user to experiment safely and learn how to use git-push properly. Originally suggested by Steffen Prohaska. Signed-off-by: Brian Ewins <brian.ewins@gmail.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'builtin-push.c')
-rw-r--r--builtin-push.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/builtin-push.c b/builtin-push.c
index 88c5024da7..141380b852 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -7,9 +7,9 @@
#include "builtin.h"
#include "remote.h"
-static const char push_usage[] = "git-push [--all] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]";
+static const char push_usage[] = "git-push [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]";
-static int all, force, thin, verbose;
+static int all, dry_run, force, thin, verbose;
static const char *receivepack;
static const char **refspec;
@@ -69,6 +69,8 @@ static int do_push(const char *repo)
argc = 1;
if (all)
argv[argc++] = "--all";
+ if (dry_run)
+ argv[argc++] = "--dry-run";
if (force)
argv[argc++] = "--force";
if (receivepack)
@@ -147,6 +149,10 @@ int cmd_push(int argc, const char **argv, const char *prefix)
all = 1;
continue;
}
+ if (!strcmp(arg, "--dry-run")) {
+ dry_run = 1;
+ continue;
+ }
if (!strcmp(arg, "--tags")) {
add_refspec("refs/tags/*");
continue;