{"thread":{"id":"10243","subject":"[PATCH 2/2] Add a --dry-run option to git-push.","startedAt":"2007-10-10T23:34:48Z","lastAt":"2007-10-10T23:34:48Z","messageCount":1,"participants":["Brian Ewins"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"55437","messageId":"6EFBD20E-5071-487E-8167-9FAAEE10A579@gmail.com","threadId":"10243","inReplyTo":null,"subject":"[PATCH 2/2] Add a --dry-run option to git-push.","fromName":"Brian Ewins","fromEmail":"brian.ewins@gmail.com","sentAt":"2007-10-10T23:34:48Z","receivedAt":"2007-10-10T23:34:48Z","isPatch":true,"sender":{"key":"brian.ewins@gmail.com","avatar":"https://gravatar.com/avatar/9ac03d89105e50a7151e695a1b4b1228151064ec3ac380a73b74ab397796baf7?d=mp&s=160"},"body":"Signed-off-by: Brian Ewins <brian.ewins@gmail.com>\n---\n  Documentation/git-push.txt |    6 +++++-\n  builtin-push.c             |   10 ++++++++--\n  t/t5516-fetch-push.sh      |   10 ++++++++++\n  3 files changed, 23 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-push.txt b/Documentation/git-push.txt\nindex 6bc559d..2dd95ba 100644\n--- a/Documentation/git-push.txt\n+++ b/Documentation/git-push.txt\n@@ -9,7 +9,7 @@ git-push - Update remote refs along with associated  \nobjects\n  SYNOPSIS\n  --------\n  [verse]\n-'git-push' [--all] [--tags] [--receive-pack=<git-receive-pack>]\n+'git-push' [--all] [--dry-run] [--tags] [--receive-pack=<git-receive- \npack>]\n             [--repo=all] [-f | --force] [-v] [<repository>  \n<refspec>...]\n\n  DESCRIPTION\n@@ -63,6 +63,10 @@ the remote repository.\n  \tInstead of naming each ref to push, specifies that all\n  \trefs under `$GIT_DIR/refs/heads/` be pushed.\n\n+\\--dry-run::\n+\tShow what would have been updated, but do not perform\n+\tany updates.\n+\n  \\--tags::\n  \tAll refs under `$GIT_DIR/refs/tags` are pushed, in\n  \taddition to refspecs explicitly listed on the command\ndiff --git a/builtin-push.c b/builtin-push.c\nindex 88c5024..141380b 100644\n--- a/builtin-push.c\n+++ b/builtin-push.c\n@@ -7,9 +7,9 @@\n  #include \"builtin.h\"\n  #include \"remote.h\"\n\n-static const char push_usage[] = \"git-push [--all] [--tags] [-- \nreceive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v]  \n[<repository> <refspec>...]\";\n+static const char push_usage[] = \"git-push [--all] [--dry-run] [-- \ntags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force]  \n[-v] [<repository> <refspec>...]\";\n\n-static int all, force, thin, verbose;\n+static int all, dry_run, force, thin, verbose;\n  static const char *receivepack;\n\n  static const char **refspec;\n@@ -69,6 +69,8 @@ static int do_push(const char *repo)\n  \targc = 1;\n  \tif (all)\n  \t\targv[argc++] = \"--all\";\n+\tif (dry_run)\n+\t\targv[argc++] = \"--dry-run\";\n  \tif (force)\n  \t\targv[argc++] = \"--force\";\n  \tif (receivepack)\n@@ -147,6 +149,10 @@ int cmd_push(int argc, const char **argv, const  \nchar *prefix)\n  \t\t\tall = 1;\n  \t\t\tcontinue;\n  \t\t}\n+\t\tif (!strcmp(arg, \"--dry-run\")) {\n+\t\t\tdry_run = 1;\n+\t\t\tcontinue;\n+\t\t}\n  \t\tif (!strcmp(arg, \"--tags\")) {\n  \t\t\tadd_refspec(\"refs/tags/*\");\n  \t\t\tcontinue;\ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex ca46aaf..4fbd5b1 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -244,4 +244,14 @@ test_expect_success 'push with colon-less  \nrefspec (4)' '\n\n  '\n\n+test_expect_success 'push with dry-run' '\n+\n+\tmk_test heads/master &&\n+\tcd testrepo &&\n+\told_commit=$(git show-ref -s --verify refs/heads/master) &&\n+\tcd .. &&\n+\tgit push --dry-run testrepo &&\n+\tcheck_push_result $old_commit heads/master\n+'\n+\n  test_done\n-- \n1.5.2.5\n"}]}