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>
This commit is contained in:
Jiang Xin 2020-08-27 11:45:42 -04:00 committed by Junio C Hamano
parent b34789c0b0
commit 917c612512
2 changed files with 7 additions and 4 deletions

View File

@ -1039,7 +1039,7 @@ test_force_fetch_tag "annotated tag" "-f -a -m'tag message'"
test_expect_success 'push --porcelain' ' test_expect_success 'push --porcelain' '
mk_empty testrepo && mk_empty testrepo &&
echo >.git/foo "To testrepo" && echo >.git/foo "To testrepo" &&
echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new branch]" && echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new reference]" &&
echo >>.git/foo "Done" && echo >>.git/foo "Done" &&
git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master && git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master &&
( (

View File

@ -500,9 +500,12 @@ static void print_ok_ref_status(struct ref *ref, int porcelain, int summary_widt
porcelain, summary_width); porcelain, summary_width);
else if (is_null_oid(&ref->old_oid)) else if (is_null_oid(&ref->old_oid))
print_ref_status('*', print_ref_status('*',
(starts_with(ref->name, "refs/tags/") ? "[new tag]" : (starts_with(ref->name, "refs/tags/")
"[new branch]"), ? "[new tag]"
ref, ref->peer_ref, NULL, porcelain, summary_width); : (starts_with(ref->name, "refs/heads/")
? "[new branch]"
: "[new reference]")),
ref, ref->peer_ref, NULL, porcelain, summary_width);
else { else {
struct strbuf quickref = STRBUF_INIT; struct strbuf quickref = STRBUF_INIT;
char type; char type;