Skip to content

Commit d0e8e09

Browse files
rsahlberggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4ff17f1 commit d0e8e09

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

Documentation/git-push.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-push - Update remote refs along with associated objects
99
SYNOPSIS
1010
--------
1111
[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>]
1313
[--repo=<repository>] [-f | --force] [--prune] [-v | --verbose]
1414
[-u | --set-upstream] [--signed]
1515
[--force-with-lease[=<refname>[:<expect>]]]
@@ -136,6 +136,11 @@ already exists on the remote side.
136136
logged. See linkgit:git-receive-pack[1] for the details
137137
on the receiving end.
138138

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+
139144
--receive-pack=<git-receive-pack>::
140145
--exec=<git-receive-pack>::
141146
Path to the 'git-receive-pack' program on the remote

builtin/push.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
487487
int flags = 0;
488488
int tags = 0;
489489
int rc;
490+
int atomic = 0;
490491
const char *repo = NULL; /* default repository */
491492
struct option options[] = {
492493
OPT__VERBOSITY(&verbosity),
@@ -518,6 +519,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
518519
OPT_BIT(0, "follow-tags", &flags, N_("push missing but relevant tags"),
519520
TRANSPORT_PUSH_FOLLOW_TAGS),
520521
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")),
521523
OPT_END()
522524
};
523525

@@ -533,6 +535,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)
533535
if (tags)
534536
add_refspec("refs/tags/*");
535537

538+
if (atomic)
539+
flags |= TRANSPORT_PUSH_ATOMIC;
540+
536541
if (argc > 0) {
537542
repo = argv[0];
538543
set_refspecs(argv + 1, argc - 1, repo);

transport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
830830
args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
831831
args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
832832
args.push_cert = !!(flags & TRANSPORT_PUSH_CERT);
833+
args.atomic = !!(flags & TRANSPORT_PUSH_ATOMIC);
833834
args.url = transport->url;
834835

835836
ret = send_pack(&args, data->fd, data->conn, remote_refs,

transport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct transport {
125125
#define TRANSPORT_PUSH_NO_HOOK 512
126126
#define TRANSPORT_PUSH_FOLLOW_TAGS 1024
127127
#define TRANSPORT_PUSH_CERT 2048
128+
#define TRANSPORT_PUSH_ATOMIC 4096
128129

129130
#define TRANSPORT_SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
130131
#define TRANSPORT_SUMMARY(x) (int)(TRANSPORT_SUMMARY_WIDTH + strlen(x) - gettext_width(x)), (x)

0 commit comments

Comments
 (0)