77#include "remote.h"
88
99static const char send_pack_usage [] =
10- "git-send-pack [--all] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
10+ "git-send-pack [--all] [--dry-run] [-- force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
1111" --all and explicit <ref> specification are mutually exclusive." ;
1212static const char * receivepack = "git-receive-pack" ;
1313static int verbose ;
1414static int send_all ;
1515static int force_update ;
1616static int use_thin_pack ;
17+ static int dry_run ;
1718
1819/*
1920 * Make a pack stream and spit it out into file descriptor fd
@@ -282,16 +283,18 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha
282283 strcpy (old_hex , sha1_to_hex (ref -> old_sha1 ));
283284 new_hex = sha1_to_hex (ref -> new_sha1 );
284285
285- if (ask_for_status_report ) {
286- packet_write (out , "%s %s %s%c%s" ,
287- old_hex , new_hex , ref -> name , 0 ,
288- "report-status" );
289- ask_for_status_report = 0 ;
290- expect_status_report = 1 ;
286+ if (!dry_run ) {
287+ if (ask_for_status_report ) {
288+ packet_write (out , "%s %s %s%c%s" ,
289+ old_hex , new_hex , ref -> name , 0 ,
290+ "report-status" );
291+ ask_for_status_report = 0 ;
292+ expect_status_report = 1 ;
293+ }
294+ else
295+ packet_write (out , "%s %s %s" ,
296+ old_hex , new_hex , ref -> name );
291297 }
292- else
293- packet_write (out , "%s %s %s" ,
294- old_hex , new_hex , ref -> name );
295298 if (will_delete_ref )
296299 fprintf (stderr , "deleting '%s'\n" , ref -> name );
297300 else {
@@ -302,7 +305,7 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha
302305 fprintf (stderr , "\n from %s\n to %s\n" ,
303306 old_hex , new_hex );
304307 }
305- if (remote ) {
308+ if (remote && ! dry_run ) {
306309 struct refspec rs ;
307310 rs .src = ref -> name ;
308311 rs .dst = NULL ;
@@ -321,7 +324,7 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha
321324 }
322325
323326 packet_flush (out );
324- if (new_refs )
327+ if (new_refs && ! dry_run )
325328 ret = pack_objects (out , remote_refs );
326329 close (out );
327330
@@ -390,6 +393,10 @@ int main(int argc, char **argv)
390393 send_all = 1 ;
391394 continue ;
392395 }
396+ if (!strcmp (arg , "--dry-run" )) {
397+ dry_run = 1 ;
398+ continue ;
399+ }
393400 if (!strcmp (arg , "--force" )) {
394401 force_update = 1 ;
395402 continue ;
0 commit comments