push.c: add an --atomic argument
Add a command line argument to the git push command to request atomic pushes. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ronnie Sahlberg committed
Jan 7, 2015 at 19:23 UTC
d0e8e09cd8828b278a56d4ebfc52d662ff8038d8
4 files changed
+13
-1
Documentation/git-push.txt
+6
-1
@@ -9,7 +9,7 @@ git-push - Update remote refs along with associated objects
9
SYNOPSIS
10
--------
11
[verse]
12
-'git push' [--all | --mirror | --tags] [--follow-tags] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
12
+'git push' [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
13
[--repo=<repository>] [-f | --force] [--prune] [-v | --verbose]
14
[-u | --set-upstream] [--signed]
15
[--force-with-lease[=<refname>[:<expect>]]]
@@ -136,6 +136,11 @@ already exists on the remote side.
136
logged. See linkgit:git-receive-pack[1] for the details
137
on the receiving end.
138
139
+--[no-]atomic::
140
+ Use an atomic transaction on the remote side if available.
141
+ Either all refs are updated, or on error, no refs are updated.
142
+ If the server does not support atomic pushes the push will fail.
143
+
144
--receive-pack=<git-receive-pack>::
145
--exec=<git-receive-pack>::
146
Path to the 'git-receive-pack' program on the remote
builtin/push.c
+5
@@ -487,6 +487,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
487
int flags = 0;
488
int tags = 0;
489
int rc;
490
+ int atomic = 0;
491
const char *repo = NULL; /* default repository */
492
struct option options[] = {
493
OPT__VERBOSITY(&verbosity),
@@ -518,6 +519,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
519
OPT_BIT(0, "follow-tags", &flags, N_("push missing but relevant tags"),
520
TRANSPORT_PUSH_FOLLOW_TAGS),
521
OPT_BIT(0, "signed", &flags, N_("GPG sign the push"), TRANSPORT_PUSH_CERT),
522
+ OPT_BOOL(0, "atomic", &atomic, N_("request atomic transaction on remote side")),
523
OPT_END()
524
};
525
@@ -533,6 +535,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)
535
if (tags)
536
add_refspec("refs/tags/*");
537
538
+ if (atomic)
539
+ flags |= TRANSPORT_PUSH_ATOMIC;
540
+
541
if (argc > 0) {
542
repo = argv[0];
543
set_refspecs(argv + 1, argc - 1, repo);
transport.c
+1
@@ -830,6 +830,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
830
args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
831
args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
832
args.push_cert = !!(flags & TRANSPORT_PUSH_CERT);
833
+ args.atomic = !!(flags & TRANSPORT_PUSH_ATOMIC);
834
args.url = transport->url;
835
836
ret = send_pack(&args, data->fd, data->conn, remote_refs,
transport.h
+1
@@ -125,6 +125,7 @@ struct transport {
125
#define TRANSPORT_PUSH_NO_HOOK 512
126
#define TRANSPORT_PUSH_FOLLOW_TAGS 1024
127
#define TRANSPORT_PUSH_CERT 2048
128
+#define TRANSPORT_PUSH_ATOMIC 4096
129
130
#define TRANSPORT_SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
131
#define TRANSPORT_SUMMARY(x) (int)(TRANSPORT_SUMMARY_WIDTH + strlen(x) - gettext_width(x)), (x)