transport-helper: improve push messages
authorFelipe Contreras <felipe.contreras@gmail.com>
Fri, 3 May 2013 23:41:59 +0000 (18:41 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sun, 5 May 2013 18:10:53 +0000 (11:10 -0700)
If there's already a remote-helper tracking ref, we can fetch the
SHA-1 to report proper push messages (as opposed to always reporting
[new branch]).

The remote-helper currently can specify the old SHA-1 to avoid this
problem, but there's no point in forcing all remote-helpers to be aware
of git commit ids; they should be able to be agnostic of them.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5801-remote-helpers.sh
transport-helper.c
index f387027c05cf502c6892c7694598bef34376be92..214aa40ca4a6fde61ae2658bd2d5e134d594ba1a 100755 (executable)
@@ -166,4 +166,18 @@ test_expect_success 'push ref with existing object' '
        compare_refs local dup server dup
 '
 
+test_expect_success 'push messages' '
+       (cd local &&
+       git checkout -b new_branch master &&
+       echo new >>file &&
+       git commit -a -m new &&
+       git push origin new_branch &&
+       git fetch origin &&
+       echo new >>file &&
+       git commit -a -m new &&
+       git push origin new_branch 2> msg &&
+       ! grep "\[new branch\]" msg
+       )
+'
+
 test_done
index dcd8d97411dd15e01ba1480a44b2a998043b424a..e561ec746855cc5c836fed02397ee8b90c1e0ae8 100644 (file)
@@ -801,6 +801,7 @@ static int push_refs_with_export(struct transport *transport,
                if (private && !get_sha1(private, sha1)) {
                        strbuf_addf(&buf, "^%s", private);
                        string_list_append(&revlist_args, strbuf_detach(&buf, NULL));
+                       hashcpy(ref->old_sha1, sha1);
                }
                free(private);