@matheusbsbs / matheus-bagliano / commits / 917c612512
Fork 0

transport: not report a non-head push as a branch

When pushing a new reference (not a head or tag), report it as a new reference instead of a new branch. Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jiang Xin committed Aug 27, 2020 at 11:45 UTC 917c612512cd4523f5587870547ee5369aa4632d
2 files changed +7 -4
t/t5516-fetch-push.sh
+1 -1
@@ -1039,7 +1039,7 @@ test_force_fetch_tag "annotated tag" "-f -a -m'tag message'"
1039 test_expect_success 'push --porcelain' '
1040 mk_empty testrepo &&
1041 echo >.git/foo "To testrepo" &&
1042 - echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new branch]" &&
1042 + echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new reference]" &&
1043 echo >>.git/foo "Done" &&
1044 git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master &&
1045 (
transport.c
+6 -3
@@ -500,9 +500,12 @@ static void print_ok_ref_status(struct ref *ref, int porcelain, int summary_widt
500 porcelain, summary_width);
501 else if (is_null_oid(&ref->old_oid))
502 print_ref_status('*',
503 - (starts_with(ref->name, "refs/tags/") ? "[new tag]" :
504 - "[new branch]"),
505 - ref, ref->peer_ref, NULL, porcelain, summary_width);
503 + (starts_with(ref->name, "refs/tags/")
504 + ? "[new tag]"
505 + : (starts_with(ref->name, "refs/heads/")
506 + ? "[new branch]"
507 + : "[new reference]")),
508 + ref, ref->peer_ref, NULL, porcelain, summary_width);
509 else {
510 struct strbuf quickref = STRBUF_INIT;
511 char type;