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>maint
parent
ee020f3598
commit
fe5d1d3eb4
|
|
@ -8,7 +8,7 @@ git-http-push - Push objects over HTTP/DAV to another repository
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
'git-http-push' [--all] [--force] [--verbose] <url> <ref> [<ref>...]
|
'git-http-push' [--all] [--dry-run] [--force] [--verbose] <url> <ref> [<ref>...]
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
|
|
@ -30,6 +30,9 @@ OPTIONS
|
||||||
the remote repository can lose commits; use it with
|
the remote repository can lose commits; use it with
|
||||||
care.
|
care.
|
||||||
|
|
||||||
|
--dry-run::
|
||||||
|
Do everything except actually send the updates.
|
||||||
|
|
||||||
--verbose::
|
--verbose::
|
||||||
Report the list of objects being walked locally and the
|
Report the list of objects being walked locally and the
|
||||||
list of objects successfully sent to the remote repository.
|
list of objects successfully sent to the remote repository.
|
||||||
|
|
|
||||||
13
http-push.c
13
http-push.c
|
|
@ -13,7 +13,7 @@
|
||||||
#include <expat.h>
|
#include <expat.h>
|
||||||
|
|
||||||
static const char http_push_usage[] =
|
static const char http_push_usage[] =
|
||||||
"git-http-push [--all] [--force] [--verbose] <remote> [<head>...]\n";
|
"git-http-push [--all] [--dry-run] [--force] [--verbose] <remote> [<head>...]\n";
|
||||||
|
|
||||||
#ifndef XML_STATUS_OK
|
#ifndef XML_STATUS_OK
|
||||||
enum XML_Status {
|
enum XML_Status {
|
||||||
|
|
@ -80,6 +80,7 @@ static struct curl_slist *default_headers;
|
||||||
static int push_verbosely;
|
static int push_verbosely;
|
||||||
static int push_all;
|
static int push_all;
|
||||||
static int force_all;
|
static int force_all;
|
||||||
|
static int dry_run;
|
||||||
|
|
||||||
static struct object_list *objects;
|
static struct object_list *objects;
|
||||||
|
|
||||||
|
|
@ -2302,6 +2303,10 @@ int main(int argc, char **argv)
|
||||||
force_all = 1;
|
force_all = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(arg, "--dry-run")) {
|
||||||
|
dry_run = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(arg, "--verbose")) {
|
if (!strcmp(arg, "--verbose")) {
|
||||||
push_verbosely = 1;
|
push_verbosely = 1;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -2443,7 +2448,8 @@ int main(int argc, char **argv)
|
||||||
if (strcmp(ref->name, ref->peer_ref->name))
|
if (strcmp(ref->name, ref->peer_ref->name))
|
||||||
fprintf(stderr, " using '%s'", ref->peer_ref->name);
|
fprintf(stderr, " using '%s'", ref->peer_ref->name);
|
||||||
fprintf(stderr, "\n from %s\n to %s\n", old_hex, new_hex);
|
fprintf(stderr, "\n from %s\n to %s\n", old_hex, new_hex);
|
||||||
|
if (dry_run)
|
||||||
|
continue;
|
||||||
|
|
||||||
/* Lock remote branch ref */
|
/* Lock remote branch ref */
|
||||||
ref_lock = lock_remote(ref->name, LOCK_TIME);
|
ref_lock = lock_remote(ref->name, LOCK_TIME);
|
||||||
|
|
@ -2511,7 +2517,8 @@ int main(int argc, char **argv)
|
||||||
if (remote->has_info_refs && new_refs) {
|
if (remote->has_info_refs && new_refs) {
|
||||||
if (info_ref_lock && remote->can_update_info_refs) {
|
if (info_ref_lock && remote->can_update_info_refs) {
|
||||||
fprintf(stderr, "Updating remote server info\n");
|
fprintf(stderr, "Updating remote server info\n");
|
||||||
update_remote_info_refs(info_ref_lock);
|
if (!dry_run)
|
||||||
|
update_remote_info_refs(info_ref_lock);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Unable to update server info\n");
|
fprintf(stderr, "Unable to update server info\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -392,6 +392,8 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
|
||||||
argv[argc++] = "--all";
|
argv[argc++] = "--all";
|
||||||
if (flags & TRANSPORT_PUSH_FORCE)
|
if (flags & TRANSPORT_PUSH_FORCE)
|
||||||
argv[argc++] = "--force";
|
argv[argc++] = "--force";
|
||||||
|
if (flags & TRANSPORT_PUSH_DRY_RUN)
|
||||||
|
argv[argc++] = "--dry-run";
|
||||||
argv[argc++] = transport->url;
|
argv[argc++] = transport->url;
|
||||||
while (refspec_nr--)
|
while (refspec_nr--)
|
||||||
argv[argc++] = *refspec++;
|
argv[argc++] = *refspec++;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue