diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-10-16 00:28:32 -0400 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2007-10-16 00:28:32 -0400 |
commit | ee020f3598f0dc86a939fb8597845594bf664898 (patch) | |
tree | 4514a121907eec45a3417f6007e9b61b6ae587c3 /transport.c | |
parent | Fix 'push --all branch...' error handling (diff) | |
download | tgif-ee020f3598f0dc86a939fb8597845594bf664898.tar.xz |
Support 'push --dry-run' for rsync transport
If the end-user requested a dry-run push we should pass that flag
though to rsync so that the rsync command can show what it would do
(or not do) if push was to be executed without the --dry-run flag.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'transport.c')
-rw-r--r-- | transport.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/transport.c b/transport.c index e363c11c05..f34d19750f 100644 --- a/transport.c +++ b/transport.c @@ -281,7 +281,7 @@ static int rsync_transport_push(struct transport *transport, struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT; int result = 0, i; struct child_process rsync; - const char *args[8]; + const char *args[10]; /* first push the objects */ @@ -291,14 +291,19 @@ static int rsync_transport_push(struct transport *transport, memset(&rsync, 0, sizeof(rsync)); rsync.argv = args; rsync.stdout_to_stderr = 1; - args[0] = "rsync"; - args[1] = (transport->verbose > 0) ? "-av" : "-a"; - args[2] = "--ignore-existing"; - args[3] = "--exclude"; - args[4] = "info"; - args[5] = get_object_directory();; - args[6] = buf.buf; - args[7] = NULL; + i = 0; + args[i++] = "rsync"; + args[i++] = "-a"; + if (flags & TRANSPORT_PUSH_DRY_RUN) + args[i++] = "--dry-run"; + if (transport->verbose > 0) + args[i++] = "-v"; + args[i++] = "--ignore-existing"; + args[i++] = "--exclude"; + args[i++] = "info"; + args[i++] = get_object_directory(); + args[i++] = buf.buf; + args[i++] = NULL; if (run_command(&rsync)) return error("Could not push objects to %s", transport->url); @@ -316,7 +321,11 @@ static int rsync_transport_push(struct transport *transport, } else if (write_refs_to_temp_dir(&temp_dir, refspec_nr, refspec)) return -1; - i = (flags & TRANSPORT_PUSH_FORCE) ? 2 : 3; + i = 2; + if (flags & TRANSPORT_PUSH_DRY_RUN) + args[i++] = "--dry-run"; + if (!(flags & TRANSPORT_PUSH_FORCE)) + args[i++] = "--ignore-existing"; args[i++] = temp_dir.buf; args[i++] = transport->url; args[i++] = NULL; |