{"thread":{"id":"10241","subject":"[PATCH 0/2] Add --dry-run option to git-push","startedAt":"2007-10-10T23:34:27Z","lastAt":"2007-10-11T20:18:11Z","messageCount":5,"participants":["Baz","Lars Hjemli","Brian Ewins"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"55435","messageId":"2faad3050710101634s5ed39bcbn723184810bc265d5@mail.gmail.com","threadId":"10241","inReplyTo":null,"subject":"[PATCH 0/2] Add --dry-run option to git-push","fromName":"Baz","fromEmail":"brian.ewins@gmail.com","sentAt":"2007-10-10T23:34:27Z","receivedAt":"2007-10-10T23:34:27Z","isPatch":true,"sender":{"key":"brian.ewins@gmail.com","avatar":"https://gravatar.com/avatar/9ac03d89105e50a7151e695a1b4b1228151064ec3ac380a73b74ab397796baf7?d=mp&s=160"},"body":"Hi,\nthere was discussion recently about the default behaviour of git-push\nhaving the potential to confuse, making it easy to push commits that\nare still cooking in other branches.\n\nIts also possible for newbies to make mistakes with refspecs, but\nthere's no way to know if you've got the syntax right without actually\npushing. Steffan suggested a dry-run flag, which I've always wanted\ntoo, so here's an attempt. Patches git-send-pack, git-push, their\ndocs, and adds a test for git-push.\n\nTreat me gentle... first patch to the list and the mailer will\nprobably mangle it (sigh)\n\nCheers,\nBaz\n\nDiffstat:\n\n Documentation/git-push.txt      |    6 +++++-\n Documentation/git-send-pack.txt |    5 ++++-\n builtin-push.c                  |   10 ++++++++--\n send-pack.c                     |   31 +++++++++++++++++++------------\n t/t5516-fetch-push.sh           |   10 ++++++++++\n 5 files changed, 46 insertions(+), 16 deletions(-)\n"},{"id":"55455","messageId":"8c5c35580710110057r29c1fe0w7f9e2825fa33@mail.gmail.com","threadId":"10241","inReplyTo":"2faad3050710101634s5ed39bcbn723184810bc265d5@mail.gmail.com","subject":"Re: [PATCH 0/2] Add --dry-run option to git-push","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-10-11T07:57:47Z","receivedAt":"2007-10-11T07:57:47Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 10/11/07, Baz <brian.ewins@gmail.com> wrote:\n> there was discussion recently about the default behaviour of git-push\n> having the potential to confuse, making it easy to push commits that\n> are still cooking in other branches.\n>\n> Its also possible for newbies to make mistakes with refspecs, but\n> there's no way to know if you've got the syntax right without actually\n> pushing. Steffan suggested a dry-run flag, which I've always wanted\n> too, so here's an attempt. Patches git-send-pack, git-push, their\n> docs, and adds a test for git-push.\n\nMaybe some of this description could be reused in the commit messages?\n\n> first patch to the list and the mailer will\n> probably mangle it (sigh)\n\nYeah, it did.\n\nWould it be possible for you to resend with git-send-email after\nadding proper commit messages? If git-send-email is not an option,\nattaching the patches are preferable to the current mangling.\n\n--\nlarsh\n"},{"id":"55496","messageId":"119213114734-git-send-email-Brian.Ewins@gmail.com","threadId":"10241","inReplyTo":"8c5c35580710110057r29c1fe0w7f9e2825fa33@mail.gmail.com","subject":"[PATCH v2 1/2] Add a --dry-run option to git-send-pack.","fromName":"Brian Ewins","fromEmail":"brian.ewins@gmail.com","sentAt":"2007-10-11T19:32:26Z","receivedAt":"2007-10-11T19:32:26Z","isPatch":true,"sender":{"key":"brian.ewins@gmail.com","avatar":"https://gravatar.com/avatar/9ac03d89105e50a7151e695a1b4b1228151064ec3ac380a73b74ab397796baf7?d=mp&s=160"},"body":"Implement support for --dry-run, so that it can be used\nin calls from git-push. With this flag set, git-send-pack\nwill not send any updates to the server.\n\nSigned-off-by: Brian Ewins <brian.ewins@gmail.com>\n---\n Documentation/git-send-pack.txt |    5 ++++-\n send-pack.c                     |   31 +++++++++++++++++++------------\n 2 files changed, 23 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-send-pack.txt b/Documentation/git-send-pack.txt\nindex 3271e88..2fa01d4 100644\n--- a/Documentation/git-send-pack.txt\n+++ b/Documentation/git-send-pack.txt\n@@ -8,7 +8,7 @@ git-send-pack - Push objects over git protocol to another repository\n \n SYNOPSIS\n --------\n-'git-send-pack' [--all] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n+'git-send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n \n DESCRIPTION\n -----------\n@@ -34,6 +34,9 @@ OPTIONS\n \tInstead of explicitly specifying which refs to update,\n \tupdate all heads that locally exist.\n \n+\\--dry-run::\n+\tDo everything except actually send the updates.\n+\n \\--force::\n \tUsually, the command refuses to update a remote ref that\n \tis not an ancestor of the local ref used to overwrite it.\ndiff --git a/send-pack.c b/send-pack.c\nindex f74e66a..16ed51f 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -7,13 +7,14 @@\n #include \"remote.h\"\n \n static const char send_pack_usage[] =\n-\"git-send-pack [--all] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\\n\"\n+\"git-send-pack [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\\n\"\n \"  --all and explicit <ref> specification are mutually exclusive.\";\n static const char *receivepack = \"git-receive-pack\";\n static int verbose;\n static int send_all;\n static int force_update;\n static int use_thin_pack;\n+static int dry_run;\n \n /*\n  * Make a pack stream and spit it out into file descriptor fd\n@@ -282,16 +283,18 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha\n \t\tstrcpy(old_hex, sha1_to_hex(ref->old_sha1));\n \t\tnew_hex = sha1_to_hex(ref->new_sha1);\n \n-\t\tif (ask_for_status_report) {\n-\t\t\tpacket_write(out, \"%s %s %s%c%s\",\n-\t\t\t\t     old_hex, new_hex, ref->name, 0,\n-\t\t\t\t     \"report-status\");\n-\t\t\task_for_status_report = 0;\n-\t\t\texpect_status_report = 1;\n+\t\tif (!dry_run) {\n+\t\t\tif (ask_for_status_report) {\n+\t\t\t\tpacket_write(out, \"%s %s %s%c%s\",\n+\t\t\t\t\told_hex, new_hex, ref->name, 0,\n+\t\t\t\t\t\"report-status\");\n+\t\t\t\task_for_status_report = 0;\n+\t\t\t\texpect_status_report = 1;\n+\t\t\t}\n+\t\t\telse\n+\t\t\t\tpacket_write(out, \"%s %s %s\",\n+\t\t\t\t\told_hex, new_hex, ref->name);\n \t\t}\n-\t\telse\n-\t\t\tpacket_write(out, \"%s %s %s\",\n-\t\t\t\t     old_hex, new_hex, ref->name);\n \t\tif (will_delete_ref)\n \t\t\tfprintf(stderr, \"deleting '%s'\\n\", ref->name);\n \t\telse {\n@@ -302,7 +305,7 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha\n \t\t\tfprintf(stderr, \"\\n  from %s\\n  to   %s\\n\",\n \t\t\t\told_hex, new_hex);\n \t\t}\n-\t\tif (remote) {\n+\t\tif (remote && !dry_run) {\n \t\t\tstruct refspec rs;\n \t\t\trs.src = ref->name;\n \t\t\trs.dst = NULL;\n@@ -321,7 +324,7 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha\n \t}\n \n \tpacket_flush(out);\n-\tif (new_refs)\n+\tif (new_refs && !dry_run)\n \t\tret = pack_objects(out, remote_refs);\n \tclose(out);\n \n@@ -390,6 +393,10 @@ int main(int argc, char **argv)\n \t\t\t\tsend_all = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--dry-run\")) {\n+\t\t\t\tdry_run = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--force\")) {\n \t\t\t\tforce_update = 1;\n \t\t\t\tcontinue;\n-- \n1.5.2.5\n"},{"id":"55497","messageId":"11921311522755-git-send-email-Brian.Ewins@gmail.com","threadId":"10241","inReplyTo":"119213114734-git-send-email-Brian.Ewins@gmail.com","subject":"[PATCH v2 2/2] Add a --dry-run option to git-push.","fromName":"Brian Ewins","fromEmail":"brian.ewins@gmail.com","sentAt":"2007-10-11T19:32:27Z","receivedAt":"2007-10-11T19:32:27Z","isPatch":true,"sender":{"key":"brian.ewins@gmail.com","avatar":"https://gravatar.com/avatar/9ac03d89105e50a7151e695a1b4b1228151064ec3ac380a73b74ab397796baf7?d=mp&s=160"},"body":"The default behaviour of git-push is potentially confusing\nfor new users, since it will push changes that are not on\nthe current branch. Publishing patches that were still\ncooking on a development branch is hard to undo.\n\nIt would also be nice to be able to verify the expansion\nof refspecs if you've edited them, so that you know\nwhat branches matched on the server.\n\nAdding a --dry-run flag allows the user to experiment\nsafely and learn how to use git-push properly. Originally\nsuggested by Steffen Prohaska.\n\nSigned-off-by: Brian Ewins <brian.ewins@gmail.com>\n---\n Documentation/git-push.txt |    5 ++++-\n builtin-push.c             |   10 ++++++++--\n t/t5516-fetch-push.sh      |   10 ++++++++++\n 3 files changed, 22 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-push.txt b/Documentation/git-push.txt\nindex 6bc559d..e5dd4c1 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 objects\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-pack>]\n            [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]\n \n DESCRIPTION\n@@ -63,6 +63,9 @@ 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+\tDo everything except actually send the 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] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]\";\n+static const char push_usage[] = \"git-push [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-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 char *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 refspec (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"},{"id":"55499","messageId":"8c5c35580710111318u63a71da2w31b8c6dde6492c6f@mail.gmail.com","threadId":"10241","inReplyTo":"119213114734-git-send-email-Brian.Ewins@gmail.com","subject":"Re: [PATCH v2 1/2] Add a --dry-run option to git-send-pack.","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-10-11T20:18:11Z","receivedAt":"2007-10-11T20:18:11Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"Thanks\n\n--\nlarsh\n"}]}