@matheusbsbs / matheus-bagliano / commits / fe5d1d3eb4
Fork 0

Support 'push --dry-run' for http transport

If the end-user requested a dry-run push we need to pass that flag over to http-push and additionally make sure it does not actually upload any changes to the remote server. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Oct 16, 2007 at 00:35 UTC fe5d1d3eb42e6cf3dca93b2277be9464b026fcf2
3 files changed +16 -4
Documentation/git-http-push.txt
+4 -1
@@ -8,7 +8,7 @@ git-http-push - Push objects over HTTP/DAV to another repository
8
9 SYNOPSIS
10 --------
11 -'git-http-push' [--all] [--force] [--verbose] <url> <ref> [<ref>...]
11 +'git-http-push' [--all] [--dry-run] [--force] [--verbose] <url> <ref> [<ref>...]
12
13 DESCRIPTION
14 -----------
@@ -30,6 +30,9 @@ OPTIONS
30 the remote repository can lose commits; use it with
31 care.
32
33 +--dry-run::
34 + Do everything except actually send the updates.
35 +
36 --verbose::
37 Report the list of objects being walked locally and the
38 list of objects successfully sent to the remote repository.
http-push.c
+10 -3
@@ -13,7 +13,7 @@
13 #include <expat.h>
14
15 static const char http_push_usage[] =
16 -"git-http-push [--all] [--force] [--verbose] <remote> [<head>...]\n";
16 +"git-http-push [--all] [--dry-run] [--force] [--verbose] <remote> [<head>...]\n";
17
18 #ifndef XML_STATUS_OK
19 enum XML_Status {
@@ -80,6 +80,7 @@ static struct curl_slist *default_headers;
80 static int push_verbosely;
81 static int push_all;
82 static int force_all;
83 +static int dry_run;
84
85 static struct object_list *objects;
86
@@ -2302,6 +2303,10 @@ int main(int argc, char **argv)
2303 force_all = 1;
2304 continue;
2305 }
2306 + if (!strcmp(arg, "--dry-run")) {
2307 + dry_run = 1;
2308 + continue;
2309 + }
2310 if (!strcmp(arg, "--verbose")) {
2311 push_verbosely = 1;
2312 continue;
@@ -2443,7 +2448,8 @@ int main(int argc, char **argv)
2448 if (strcmp(ref->name, ref->peer_ref->name))
2449 fprintf(stderr, " using '%s'", ref->peer_ref->name);
2450 fprintf(stderr, "\n from %s\n to %s\n", old_hex, new_hex);
2446 -
2451 + if (dry_run)
2452 + continue;
2453
2454 /* Lock remote branch ref */
2455 ref_lock = lock_remote(ref->name, LOCK_TIME);
@@ -2511,7 +2517,8 @@ int main(int argc, char **argv)
2517 if (remote->has_info_refs && new_refs) {
2518 if (info_ref_lock && remote->can_update_info_refs) {
2519 fprintf(stderr, "Updating remote server info\n");
2514 - update_remote_info_refs(info_ref_lock);
2520 + if (!dry_run)
2521 + update_remote_info_refs(info_ref_lock);
2522 } else {
2523 fprintf(stderr, "Unable to update server info\n");
2524 }
transport.c
+2
@@ -392,6 +392,8 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
392 argv[argc++] = "--all";
393 if (flags & TRANSPORT_PUSH_FORCE)
394 argv[argc++] = "--force";
395 + if (flags & TRANSPORT_PUSH_DRY_RUN)
396 + argv[argc++] = "--dry-run";
397 argv[argc++] = transport->url;
398 while (refspec_nr--)
399 argv[argc++] = *refspec++;