{"thread":{"id":"10242","subject":"[PATCH 1/2] Add a --dry-run option to git-send-pack.","startedAt":"2007-10-10T23:34:43Z","lastAt":"2007-10-10T23:34:43Z","messageCount":1,"participants":["Brian Ewins"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"55436","messageId":"0D259CA7-819C-4479-BBC6-232790C055D2@gmail.com","threadId":"10242","inReplyTo":null,"subject":"[PATCH 1/2] Add a --dry-run option to git-send-pack.","fromName":"Brian Ewins","fromEmail":"brian.ewins@gmail.com","sentAt":"2007-10-10T23:34:43Z","receivedAt":"2007-10-10T23:34:43Z","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-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- \npack.txt\nindex 3271e88..9e2783c 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  \nanother repository\n\n  SYNOPSIS\n  --------\n-'git-send-pack' [--all] [--force] [--receive-pack=<git-receive- \npack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n+'git-send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git- \nreceive-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+\tShow what would have been updated, but do not send any 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..e8bef4f 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>]  \n[--verbose] [--thin] [<host>:]<directory> [<ref>...]\\n\"\n+\"git-send-pack [--all] [--dry-run] [--force] [--receive-pack=<git- \nreceive-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  \nremote *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\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  \nremote *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  \nremote *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"}]}