Re: [PATCH v2 2/7] send-pack.c: add an --atomic-push command line argument

2014-11-04 Thread Ronnie Sahlberg
Fixed. Thanks


On Tue, Nov 4, 2014 at 2:17 PM, Stefan Beller  wrote:
> On Mon, Nov 3, 2014 at 11:12 AM, Ronnie Sahlberg  wrote:
>> This adds support to send-pack to to negotiate and use atomic pushes
>
> /s/to to/to/
>
>> iff the server supports it. Atomic pushes are activated by a new command
>> line flag --atomic-push.
>>
>> In order to do this we also need to change the semantics for send_pack()
>> slightly. The existing send_pack() function actually don't sent all the
>> refs back to the server when multiple refs are involved, for example
>> when using --all. Several of the failure modes for pushes can already be
>> detected locally in the send_pack client based on the information from the
>> initial server side list of all the refs as generated by receive-pack.
>> Any such refs that we thus know would fail to push are thus pruned from
>> the list of refs we send to the server to update.
>>
>> For atomic pushes, we have to deal thus with both failures that are detected
>> locally as well as failures that are reported back from the server. In order
>> to do so we treat all local failures as push failures too.
>>
>> We introduce a new status code REF_STATUS_ATOMIC_PUSH_FAILED so we can
>> flag all refs that we would normally have tried to push to the server
>> but we did not due to local failures. This is to improve the error message
>> back to the end user to flag that "these refs failed to update since the
>> atomic push operation failed."
>>
>> Signed-off-by: Ronnie Sahlberg 
>> ---
>>  Documentation/git-send-pack.txt |  7 ++-
>>  builtin/send-pack.c |  6 +-
>>  remote.h|  3 ++-
>>  send-pack.c | 39 ++-
>>  send-pack.h |  1 +
>>  transport.c |  4 
>>  6 files changed, 52 insertions(+), 8 deletions(-)
>>
>> diff --git a/Documentation/git-send-pack.txt 
>> b/Documentation/git-send-pack.txt
>> index 2a0de42..9296587 100644
>> --- a/Documentation/git-send-pack.txt
>> +++ b/Documentation/git-send-pack.txt
>> @@ -9,7 +9,7 @@ git-send-pack - Push objects over Git protocol to another 
>> repository
>>  SYNOPSIS
>>  
>>  [verse]
>> -'git send-pack' [--all] [--dry-run] [--force] 
>> [--receive-pack=] [--verbose] [--thin] 
>> [:] [...]
>> +'git send-pack' [--all] [--dry-run] [--force] 
>> [--receive-pack=] [--verbose] [--thin] [--atomic-push] 
>> [:] [...]
>>
>>  DESCRIPTION
>>  ---
>> @@ -62,6 +62,11 @@ be in a separate packet, and the list must end with a 
>> flush packet.
>> Send a "thin" pack, which records objects in deltified form based
>> on objects not included in the pack to reduce network traffic.
>>
>> +--atomic-push::
>> +   Use an atomic transaction for updating the refs. If any of the refs
>> +   fails to update then the entire push will fail without changing any
>> +   refs.
>> +
>>  ::
>> A remote host to house the repository.  When this
>> part is specified, 'git-receive-pack' is invoked via
>> diff --git a/builtin/send-pack.c b/builtin/send-pack.c
>> index b564a77..93cb17c 100644
>> --- a/builtin/send-pack.c
>> +++ b/builtin/send-pack.c
>> @@ -13,7 +13,7 @@
>>  #include "sha1-array.h"
>>
>>  static const char send_pack_usage[] =
>> -"git send-pack [--all | --mirror] [--dry-run] [--force] 
>> [--receive-pack=] [--verbose] [--thin] 
>> [:] [...]\n"
>> +"git send-pack [--all | --mirror] [--dry-run] [--force] 
>> [--receive-pack=] [--verbose] [--thin] [--atomic-push] 
>> [:] [...]\n"
>>  "  --all and explicit  specification are mutually exclusive.";
>>
>>  static struct send_pack_args args;
>> @@ -170,6 +170,10 @@ int cmd_send_pack(int argc, const char **argv, const 
>> char *prefix)
>> args.use_thin_pack = 1;
>> continue;
>> }
>> +   if (!strcmp(arg, "--atomic-push")) {
>> +   args.use_atomic_push = 1;
>> +   continue;
>> +   }
>> if (!strcmp(arg, "--stateless-rpc")) {
>> args.stateless_rpc = 1;
>> continue;
>> diff --git a/remote.h b/remote.h
>> index 8b62efd..f346524 100644
>> --- a/remote.h
>> +++ b/remote.h
>> @@ -115,7 +115,8 @@ struct ref {
>> REF_STATUS_REJECT_SHALLOW,
>> REF_STATUS_UPTODATE,
>> REF_STATUS_REMOTE_REJECT,
>> -   REF_STATUS_EXPECTING_REPORT
>> +   REF_STATUS_EXPECTING_REPORT,
>> +   REF_STATUS_ATOMIC_PUSH_FAILED
>> } status;
>> char *remote_status;
>> struct ref *peer_ref; /* when renaming */
>> diff --git a/send-pack.c b/send-pack.c
>> index 1ccc84c..08602a8 100644
>> --- a/send-pack.c
>> +++ b/send-pack.c
>> @@ -190,7 +190,7 @@ static void advertise_shallow_grafts_buf(struct strbuf 
>> *sb)
>>   

Re: [PATCH v2 2/7] send-pack.c: add an --atomic-push command line argument

2014-11-04 Thread Stefan Beller
On Mon, Nov 3, 2014 at 11:12 AM, Ronnie Sahlberg  wrote:
> This adds support to send-pack to to negotiate and use atomic pushes

/s/to to/to/

> iff the server supports it. Atomic pushes are activated by a new command
> line flag --atomic-push.
>
> In order to do this we also need to change the semantics for send_pack()
> slightly. The existing send_pack() function actually don't sent all the
> refs back to the server when multiple refs are involved, for example
> when using --all. Several of the failure modes for pushes can already be
> detected locally in the send_pack client based on the information from the
> initial server side list of all the refs as generated by receive-pack.
> Any such refs that we thus know would fail to push are thus pruned from
> the list of refs we send to the server to update.
>
> For atomic pushes, we have to deal thus with both failures that are detected
> locally as well as failures that are reported back from the server. In order
> to do so we treat all local failures as push failures too.
>
> We introduce a new status code REF_STATUS_ATOMIC_PUSH_FAILED so we can
> flag all refs that we would normally have tried to push to the server
> but we did not due to local failures. This is to improve the error message
> back to the end user to flag that "these refs failed to update since the
> atomic push operation failed."
>
> Signed-off-by: Ronnie Sahlberg 
> ---
>  Documentation/git-send-pack.txt |  7 ++-
>  builtin/send-pack.c |  6 +-
>  remote.h|  3 ++-
>  send-pack.c | 39 ++-
>  send-pack.h |  1 +
>  transport.c |  4 
>  6 files changed, 52 insertions(+), 8 deletions(-)
>
> diff --git a/Documentation/git-send-pack.txt b/Documentation/git-send-pack.txt
> index 2a0de42..9296587 100644
> --- a/Documentation/git-send-pack.txt
> +++ b/Documentation/git-send-pack.txt
> @@ -9,7 +9,7 @@ git-send-pack - Push objects over Git protocol to another 
> repository
>  SYNOPSIS
>  
>  [verse]
> -'git send-pack' [--all] [--dry-run] [--force] 
> [--receive-pack=] [--verbose] [--thin] [:] 
> [...]
> +'git send-pack' [--all] [--dry-run] [--force] 
> [--receive-pack=] [--verbose] [--thin] [--atomic-push] 
> [:] [...]
>
>  DESCRIPTION
>  ---
> @@ -62,6 +62,11 @@ be in a separate packet, and the list must end with a 
> flush packet.
> Send a "thin" pack, which records objects in deltified form based
> on objects not included in the pack to reduce network traffic.
>
> +--atomic-push::
> +   Use an atomic transaction for updating the refs. If any of the refs
> +   fails to update then the entire push will fail without changing any
> +   refs.
> +
>  ::
> A remote host to house the repository.  When this
> part is specified, 'git-receive-pack' is invoked via
> diff --git a/builtin/send-pack.c b/builtin/send-pack.c
> index b564a77..93cb17c 100644
> --- a/builtin/send-pack.c
> +++ b/builtin/send-pack.c
> @@ -13,7 +13,7 @@
>  #include "sha1-array.h"
>
>  static const char send_pack_usage[] =
> -"git send-pack [--all | --mirror] [--dry-run] [--force] 
> [--receive-pack=] [--verbose] [--thin] [:] 
> [...]\n"
> +"git send-pack [--all | --mirror] [--dry-run] [--force] 
> [--receive-pack=] [--verbose] [--thin] [--atomic-push] 
> [:] [...]\n"
>  "  --all and explicit  specification are mutually exclusive.";
>
>  static struct send_pack_args args;
> @@ -170,6 +170,10 @@ int cmd_send_pack(int argc, const char **argv, const 
> char *prefix)
> args.use_thin_pack = 1;
> continue;
> }
> +   if (!strcmp(arg, "--atomic-push")) {
> +   args.use_atomic_push = 1;
> +   continue;
> +   }
> if (!strcmp(arg, "--stateless-rpc")) {
> args.stateless_rpc = 1;
> continue;
> diff --git a/remote.h b/remote.h
> index 8b62efd..f346524 100644
> --- a/remote.h
> +++ b/remote.h
> @@ -115,7 +115,8 @@ struct ref {
> REF_STATUS_REJECT_SHALLOW,
> REF_STATUS_UPTODATE,
> REF_STATUS_REMOTE_REJECT,
> -   REF_STATUS_EXPECTING_REPORT
> +   REF_STATUS_EXPECTING_REPORT,
> +   REF_STATUS_ATOMIC_PUSH_FAILED
> } status;
> char *remote_status;
> struct ref *peer_ref; /* when renaming */
> diff --git a/send-pack.c b/send-pack.c
> index 1ccc84c..08602a8 100644
> --- a/send-pack.c
> +++ b/send-pack.c
> @@ -190,7 +190,7 @@ static void advertise_shallow_grafts_buf(struct strbuf 
> *sb)
> for_each_commit_graft(advertise_shallow_grafts_cb, sb);
>  }
>
> -static int ref_update_to_be_sent(const struct ref *ref, const struct 
> send_pack_args *args)
> +static int ref_update_to_be_s

[PATCH v2 2/7] send-pack.c: add an --atomic-push command line argument

2014-11-03 Thread Ronnie Sahlberg
This adds support to send-pack to to negotiate and use atomic pushes
iff the server supports it. Atomic pushes are activated by a new command
line flag --atomic-push.

In order to do this we also need to change the semantics for send_pack()
slightly. The existing send_pack() function actually don't sent all the
refs back to the server when multiple refs are involved, for example
when using --all. Several of the failure modes for pushes can already be
detected locally in the send_pack client based on the information from the
initial server side list of all the refs as generated by receive-pack.
Any such refs that we thus know would fail to push are thus pruned from
the list of refs we send to the server to update.

For atomic pushes, we have to deal thus with both failures that are detected
locally as well as failures that are reported back from the server. In order
to do so we treat all local failures as push failures too.

We introduce a new status code REF_STATUS_ATOMIC_PUSH_FAILED so we can
flag all refs that we would normally have tried to push to the server
but we did not due to local failures. This is to improve the error message
back to the end user to flag that "these refs failed to update since the
atomic push operation failed."

Signed-off-by: Ronnie Sahlberg 
---
 Documentation/git-send-pack.txt |  7 ++-
 builtin/send-pack.c |  6 +-
 remote.h|  3 ++-
 send-pack.c | 39 ++-
 send-pack.h |  1 +
 transport.c |  4 
 6 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/Documentation/git-send-pack.txt b/Documentation/git-send-pack.txt
index 2a0de42..9296587 100644
--- a/Documentation/git-send-pack.txt
+++ b/Documentation/git-send-pack.txt
@@ -9,7 +9,7 @@ git-send-pack - Push objects over Git protocol to another 
repository
 SYNOPSIS
 
 [verse]
-'git send-pack' [--all] [--dry-run] [--force] 
[--receive-pack=] [--verbose] [--thin] [:] 
[...]
+'git send-pack' [--all] [--dry-run] [--force] 
[--receive-pack=] [--verbose] [--thin] [--atomic-push] 
[:] [...]
 
 DESCRIPTION
 ---
@@ -62,6 +62,11 @@ be in a separate packet, and the list must end with a flush 
packet.
Send a "thin" pack, which records objects in deltified form based
on objects not included in the pack to reduce network traffic.
 
+--atomic-push::
+   Use an atomic transaction for updating the refs. If any of the refs
+   fails to update then the entire push will fail without changing any
+   refs.
+
 ::
A remote host to house the repository.  When this
part is specified, 'git-receive-pack' is invoked via
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index b564a77..93cb17c 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -13,7 +13,7 @@
 #include "sha1-array.h"
 
 static const char send_pack_usage[] =
-"git send-pack [--all | --mirror] [--dry-run] [--force] 
[--receive-pack=] [--verbose] [--thin] [:] 
[...]\n"
+"git send-pack [--all | --mirror] [--dry-run] [--force] 
[--receive-pack=] [--verbose] [--thin] [--atomic-push] 
[:] [...]\n"
 "  --all and explicit  specification are mutually exclusive.";
 
 static struct send_pack_args args;
@@ -170,6 +170,10 @@ int cmd_send_pack(int argc, const char **argv, const char 
*prefix)
args.use_thin_pack = 1;
continue;
}
+   if (!strcmp(arg, "--atomic-push")) {
+   args.use_atomic_push = 1;
+   continue;
+   }
if (!strcmp(arg, "--stateless-rpc")) {
args.stateless_rpc = 1;
continue;
diff --git a/remote.h b/remote.h
index 8b62efd..f346524 100644
--- a/remote.h
+++ b/remote.h
@@ -115,7 +115,8 @@ struct ref {
REF_STATUS_REJECT_SHALLOW,
REF_STATUS_UPTODATE,
REF_STATUS_REMOTE_REJECT,
-   REF_STATUS_EXPECTING_REPORT
+   REF_STATUS_EXPECTING_REPORT,
+   REF_STATUS_ATOMIC_PUSH_FAILED
} status;
char *remote_status;
struct ref *peer_ref; /* when renaming */
diff --git a/send-pack.c b/send-pack.c
index 1ccc84c..08602a8 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -190,7 +190,7 @@ static void advertise_shallow_grafts_buf(struct strbuf *sb)
for_each_commit_graft(advertise_shallow_grafts_cb, sb);
 }
 
-static int ref_update_to_be_sent(const struct ref *ref, const struct 
send_pack_args *args)
+static int ref_update_to_be_sent(const struct ref *ref, const struct 
send_pack_args *args, int *atomic_push_failed)
 {
if (!ref->peer_ref && !args->send_mirror)
return 0;
@@ -203,6 +203,12 @@ static int ref_update_to_be_sent(const struct ref *ref, 
const struct send_pack_a
case REF_STATUS_RE