Skip to content

Commit 606475f

Browse files
martinxyzgitster
authored andcommitted
Remove filename from conflict markers
Put filenames into the conflict markers only when they are different. Otherwise they are redundant information clutter. Print the filename explicitely when warning about a binary conflict. Signed-off-by: Martin Renold <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 702beb3 commit 606475f

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

ll-merge.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
5555

5656
static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
5757
mmbuffer_t *result,
58-
const char *path_unused,
58+
const char *path,
5959
mmfile_t *orig,
6060
mmfile_t *src1, const char *name1,
6161
mmfile_t *src2, const char *name2,
@@ -67,10 +67,10 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
6767
if (buffer_is_binary(orig->ptr, orig->size) ||
6868
buffer_is_binary(src1->ptr, src1->size) ||
6969
buffer_is_binary(src2->ptr, src2->size)) {
70-
warning("Cannot merge binary files: %s vs. %s\n",
71-
name1, name2);
70+
warning("Cannot merge binary files: %s (%s vs. %s)\n",
71+
path, name1, name2);
7272
return ll_binary_merge(drv_unused, result,
73-
path_unused,
73+
path,
7474
orig, src1, name1,
7575
src2, name2,
7676
virtual_ancestor);

merge-recursive.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,13 @@ static int merge_3way(struct merge_options *o,
622622
char *name1, *name2;
623623
int merge_status;
624624

625-
name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
626-
name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
625+
if (strcmp(a->path, b->path)) {
626+
name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
627+
name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
628+
} else {
629+
name1 = xstrdup(mkpath("%s", branch1));
630+
name2 = xstrdup(mkpath("%s", branch2));
631+
}
627632

628633
fill_mm(one->sha1, &orig);
629634
fill_mm(a->sha1, &src1);

t/t3404-rebase-interactive.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ index e69de29..00750ed 100644
119119
EOF
120120

121121
cat > expect2 << EOF
122-
<<<<<<< HEAD:file1
122+
<<<<<<< HEAD
123123
2
124124
=======
125125
3
126-
>>>>>>> b7ca976... G:file1
126+
>>>>>>> b7ca976... G
127127
EOF
128128

129129
test_expect_success 'stop on conflicting pick' '

t/t6024-recursive-merge.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,18 @@ test_expect_success "combined merge conflicts" "
6565
"
6666

6767
cat > expect << EOF
68-
<<<<<<< HEAD:a1
68+
<<<<<<< HEAD
6969
F
7070
=======
7171
G
72-
>>>>>>> G:a1
72+
>>>>>>> G
7373
EOF
7474

7575
test_expect_success "result contains a conflict" "test_cmp expect a1"
7676

7777
git ls-files --stage > out
7878
cat > expect << EOF
79-
100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1 a1
79+
100644 439cc46de773d8a83c77799b7cc9191c128bfcff 1 a1
8080
100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1
8181
100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
8282
EOF
@@ -93,8 +93,7 @@ test_expect_success 'refuse to merge binary files' '
9393
git add binary-file &&
9494
git commit -m binary2 &&
9595
test_must_fail git merge F > merge.out 2> merge.err &&
96-
grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \
97-
merge.err
96+
grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge.err
9897
'
9998

10099
test_expect_success 'mark rename/delete as unmerged' '

0 commit comments

Comments
 (0)