Skip to content

Commit 917c612

Browse files
jiangxingitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b34789c commit 917c612

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

t/t5516-fetch-push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ test_force_fetch_tag "annotated tag" "-f -a -m'tag message'"
10391039
test_expect_success 'push --porcelain' '
10401040
mk_empty testrepo &&
10411041
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]" &&
10431043
echo >>.git/foo "Done" &&
10441044
git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master &&
10451045
(

transport.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,12 @@ static void print_ok_ref_status(struct ref *ref, int porcelain, int summary_widt
500500
porcelain, summary_width);
501501
else if (is_null_oid(&ref->old_oid))
502502
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);
506509
else {
507510
struct strbuf quickref = STRBUF_INIT;
508511
char type;

0 commit comments

Comments
 (0)