Skip to content

Commit 69a8b7c

Browse files
peffgitster
authored andcommitted
merge: indicate remote tracking branches in merge message
Previously when merging directly from a local tracking branch like: git merge origin/master The merge message said: Merge commit 'origin/master' * commit 'origin/master': ... Instead, let's be more explicit about what we are merging: Merge remote branch 'origin/master' * origin/master: ... We accomplish this by recognizing remote tracking branches in git-merge when we build the simulated FETCH_HEAD output that we feed to fmt-merge-msg. In addition to a new test in t7608, we have to tweak the expected output of t3409, which does such a merge. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 751c597 commit 69a8b7c

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

builtin-merge.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ static void merge_name(const char *remote, struct strbuf *msg)
375375
sha1_to_hex(branch_head), remote);
376376
goto cleanup;
377377
}
378+
if (!prefixcmp(found_ref, "refs/remotes/")) {
379+
strbuf_addf(msg, "%s\t\tremote branch '%s' of .\n",
380+
sha1_to_hex(branch_head), remote);
381+
goto cleanup;
382+
}
378383
}
379384

380385
/* See if remote matches <name>^^^.. or <name>~<number> */

t/t3409-rebase-preserve-merges.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ test_expect_success 'rebase -p fakes interactive rebase' '
7171
git fetch &&
7272
git rebase -p origin/topic &&
7373
test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
74-
test 1 = $(git rev-list --all --pretty=oneline | grep "Merge commit" | wc -l)
74+
test 1 = $(git rev-list --all --pretty=oneline | grep "Merge remote branch " | wc -l)
7575
)
7676
'
7777

t/t7608-merge-messages.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,14 @@ test_expect_success 'ambiguous tag' '
4747
check_oneline "Merge commit QambiguousQ"
4848
'
4949

50+
test_expect_success 'remote branch' '
51+
git checkout -b remote master &&
52+
test_commit remote-1 &&
53+
git update-ref refs/remotes/origin/master remote &&
54+
git checkout master &&
55+
test_commit master-5 &&
56+
git merge origin/master &&
57+
check_oneline "Merge remote branch Qorigin/masterQ"
58+
'
59+
5060
test_done

0 commit comments

Comments
 (0)