[PATCH 2/2] Add a --dry-run option to git-push.
From: Brian Ewins <hidden>
Date: 2016-06-15 22:43:40
Subsystem:
documentation, the rest · Maintainers:
Jonathan Corbet, Linus Torvalds
Signed-off-by: Brian Ewins <redacted> --- Documentation/git-push.txt | 6 +++++- builtin-push.c | 10 ++++++++-- t/t5516-fetch-push.sh | 10 ++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 6bc559d..2dd95ba 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] [--tags] [--receive-pack=<git-receive-pack>]
+'git-push' [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-
pack>]
[--repo=all] [-f | --force] [-v] [<repository>
<refspec>...]
DESCRIPTION@@ -63,6 +63,10 @@ the remote repository. Instead of naming each ref to push, specifies that all refs under `$GIT_DIR/refs/heads/` be pushed. +\--dry-run:: + Show what would have been updated, but do not perform + any updates. + \--tags:: All refs under `$GIT_DIR/refs/tags` are pushed, in addition to refspecs explicitly listed on the command
diff --git a/builtin-push.c b/builtin-push.c
index 88c5024..141380b 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;diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index ca46aaf..4fbd5b1 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh@@ -244,4 +244,14 @@ test_expect_success 'push with colon-less refspec (4)' ' ' +test_expect_success 'push with dry-run' ' + + mk_test heads/master && + cd testrepo && + old_commit=$(git show-ref -s --verify refs/heads/master) && + cd .. && + git push --dry-run testrepo && + check_push_result $old_commit heads/master +' + test_done -- 1.5.2.5