git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Remove filename from conflict markers
@ 2009-06-28 15:45 Martin Renold
  2009-06-30 22:16 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Martin Renold @ 2009-06-28 15:45 UTC (permalink / raw)
  To: git

Put filenames into the conflict markers only when they are different.
Otherwise they are redundant information clutter.

Signed-off-by: Martin Renold <martinxyz@gmx.ch>
---
 merge-recursive.c             |    9 +++++++--
 t/t3404-rebase-interactive.sh |    4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index c703445..53cad96 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -622,8 +622,13 @@ static int merge_3way(struct merge_options *o,
 	char *name1, *name2;
 	int merge_status;
 
-	name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
-	name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
+	if (strcmp(a->path, b->path)) {
+		name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
+		name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
+	} else {
+		name1 = xstrdup(mkpath("%s", branch1));
+		name2 = xstrdup(mkpath("%s", branch2));
+	}
 
 	fill_mm(one->sha1, &orig);
 	fill_mm(a->sha1, &src1);
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index c32ff66..a973628 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -119,11 +119,11 @@ index e69de29..00750ed 100644
 EOF
 
 cat > expect2 << EOF
-<<<<<<< HEAD:file1
+<<<<<<< HEAD
 2
 =======
 3
->>>>>>> b7ca976... G:file1
+>>>>>>> b7ca976... G
 EOF
 
 test_expect_success 'stop on conflicting pick' '
-- 
1.6.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Remove filename from conflict markers
  2009-06-28 15:45 [PATCH] Remove filename from conflict markers Martin Renold
@ 2009-06-30 22:16 ` Junio C Hamano
  2009-07-01  3:33   ` Nanako Shiraishi
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2009-06-30 22:16 UTC (permalink / raw)
  To: Martin Renold; +Cc: git

Martin Renold <martinxyz@gmx.ch> writes:

> Put filenames into the conflict markers only when they are different.
> Otherwise they are redundant information clutter.
>
> Signed-off-by: Martin Renold <martinxyz@gmx.ch>
> ---
>  merge-recursive.c             |    9 +++++++--
>  t/t3404-rebase-interactive.sh |    4 ++--

The change seems to break more tests than just 3404.

I also wondered briefly if it will break people's existing scripts;
I suspect it will not likely to be a huge problem.

>  2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/merge-recursive.c b/merge-recursive.c
> index c703445..53cad96 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -622,8 +622,13 @@ static int merge_3way(struct merge_options *o,
>  	char *name1, *name2;
>  	int merge_status;
>  
> -	name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
> -	name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
> +	if (strcmp(a->path, b->path)) {
> +		name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
> +		name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
> +	} else {
> +		name1 = xstrdup(mkpath("%s", branch1));
> +		name2 = xstrdup(mkpath("%s", branch2));
> +	}
>  
>  	fill_mm(one->sha1, &orig);
>  	fill_mm(a->sha1, &src1);
> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
> index c32ff66..a973628 100755
> --- a/t/t3404-rebase-interactive.sh
> +++ b/t/t3404-rebase-interactive.sh
> @@ -119,11 +119,11 @@ index e69de29..00750ed 100644
>  EOF
>  
>  cat > expect2 << EOF
> -<<<<<<< HEAD:file1
> +<<<<<<< HEAD
>  2
>  =======
>  3
> ->>>>>>> b7ca976... G:file1
> +>>>>>>> b7ca976... G
>  EOF
>  
>  test_expect_success 'stop on conflicting pick' '
> -- 
> 1.6.3.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Remove filename from conflict markers
  2009-06-30 22:16 ` Junio C Hamano
@ 2009-07-01  3:33   ` Nanako Shiraishi
  2009-07-01  7:56     ` Martin Renold
  0 siblings, 1 reply; 8+ messages in thread
From: Nanako Shiraishi @ 2009-07-01  3:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Martin Renold, git

Quoting Junio C Hamano <gitster@pobox.com>:

> Martin Renold <martinxyz@gmx.ch> writes:
>
>> Put filenames into the conflict markers only when they are different.
>> Otherwise they are redundant information clutter.
>>
>> Signed-off-by: Martin Renold <martinxyz@gmx.ch>
>> ---
>>  merge-recursive.c             |    9 +++++++--
>>  t/t3404-rebase-interactive.sh |    4 ++--
>
> The change seems to break more tests than just 3404.
>
> I also wondered briefly if it will break people's existing scripts;
> I suspect it will not likely to be a huge problem.

I needed to apply the attached patch to make the tests pass. The last part clearly shows that this change introduces a usability regression. In the error message the user can no longer see which file was problematic.

I request Martin's patch to be dropped.

 t/t6024-recursive-merge.sh |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh
index 129fa30..a9c4a02 100755
--- a/t/t6024-recursive-merge.sh
+++ b/t/t6024-recursive-merge.sh
@@ -65,18 +65,18 @@ test_expect_success "combined merge conflicts" "
 "
 
 cat > expect << EOF
-<<<<<<< HEAD:a1
+<<<<<<< HEAD
 F
 =======
 G
->>>>>>> G:a1
+>>>>>>> G
 EOF
 
 test_expect_success "result contains a conflict" "test_cmp expect a1"
 
 git ls-files --stage > out
 cat > expect << EOF
-100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1	a1
+100644 439cc46de773d8a83c77799b7cc9191c128bfcff 1	a1
 100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2	a1
 100644 fd7923529855d0b274795ae3349c5e0438333979 3	a1
 EOF
@@ -93,7 +93,7 @@ test_expect_success 'refuse to merge binary files' '
 	git add binary-file &&
 	git commit -m binary2 &&
 	test_must_fail git merge F > merge.out 2> merge.err &&
-	grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \
+	grep "Cannot merge binary files: HEAD vs. F" \
 		merge.err
 '

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Remove filename from conflict markers
  2009-07-01  3:33   ` Nanako Shiraishi
@ 2009-07-01  7:56     ` Martin Renold
  2009-07-01  8:36       ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Martin Renold @ 2009-07-01  7:56 UTC (permalink / raw)
  To: Nanako Shiraishi; +Cc: Junio C Hamano, git

On Wed, Jul 01, 2009 at 12:33:10PM +0900, Nanako Shiraishi wrote:
> The last part clearly shows that this change introduces a usability
> regression.  In the error message the user can no longer see which file
> was problematic.

Not true. The filename is still printed two times in the case of "git
merge", and four times with "git rebase".  The user still sees the required
information, there are just fewer repetitions.

The previous warning was a bit nicer for copy-paste, allthough I don't see
why it should print things so differently compared to textual conflicts.

> -     grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \
> +     grep "Cannot merge binary files: HEAD vs. F" \
>               merge.err

We could als fix that test by expecting the filename on stdout:

diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh
index 129fa30..0c6b1ea 100755
--- a/t/t6024-recursive-merge.sh
+++ b/t/t6024-recursive-merge.sh
@@ -65,18 +65,18 @@ test_expect_success "combined merge conflicts" "
 "
 
 cat > expect << EOF
-<<<<<<< HEAD:a1
+<<<<<<< HEAD
 F
 =======
 G
->>>>>>> G:a1
+>>>>>>> G
 EOF
 
 test_expect_success "result contains a conflict" "test_cmp expect a1"
 
 git ls-files --stage > out
 cat > expect << EOF
-100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1      a1
+100644 439cc46de773d8a83c77799b7cc9191c128bfcff 1      a1
 100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2      a1
 100644 fd7923529855d0b274795ae3349c5e0438333979 3      a1
 EOF
@@ -93,8 +93,8 @@ test_expect_success 'refuse to merge binary files' '
        git add binary-file &&
        git commit -m binary2 &&
        test_must_fail git merge F > merge.out 2> merge.err &&
-       grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \
-               merge.err
+       grep "Cannot merge binary files: HEAD vs. F" merge.err
+       grep "Merge conflict in binary-file" merge.out
 '
 
 test_expect_success 'mark rename/delete as unmerged' '

bye,
Martin

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Remove filename from conflict markers
  2009-07-01  7:56     ` Martin Renold
@ 2009-07-01  8:36       ` Junio C Hamano
  2009-07-01 16:16         ` Martin Renold
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2009-07-01  8:36 UTC (permalink / raw)
  To: Martin Renold; +Cc: Nanako Shiraishi, Junio C Hamano, git

Martin Renold <martinxyz@gmx.ch> writes:

>  test_expect_success "result contains a conflict" "test_cmp expect a1"
>  
>  git ls-files --stage > out
>  cat > expect << EOF
> -100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1      a1
> +100644 439cc46de773d8a83c77799b7cc9191c128bfcff 1      a1
>  100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2      a1
>  100644 fd7923529855d0b274795ae3349c5e0438333979 3      a1
>  EOF

I think Nana's patch also had this, but what is this hunk about?  IOW, why
does stage #1 (common ancestor's version) even change?

Is this a virtual ancestor in a criss-cross recursive merge?

> @@ -93,8 +93,8 @@ test_expect_success 'refuse to merge binary files' '
>         git add binary-file &&
>         git commit -m binary2 &&
>         test_must_fail git merge F > merge.out 2> merge.err &&
> -       grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \
> -               merge.err
> +       grep "Cannot merge binary files: HEAD vs. F" merge.err
> +       grep "Merge conflict in binary-file" merge.out
>  '

At the end of the first "grep" && is missing.  But more importantly, would
this new output format really as informative as you claim, even when the
file that cannot be automerged due to its binaryness is not named
"binary-file" but simply say "X"?  The merge.err output shows that there
were some file that failed to merge due to being binary, and merge.out
output owuld show that "X" had conflict.  Would it be just as easy for the
end user to connect these two as it used to be?

I for now am assuming no mechanical end user is parsing this output to
figure out what to do, but that assumption might even be wrong.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Remove filename from conflict markers
  2009-07-01  8:36       ` Junio C Hamano
@ 2009-07-01 16:16         ` Martin Renold
  2009-07-01 20:18           ` [PATCH/v2] " Martin Renold
  0 siblings, 1 reply; 8+ messages in thread
From: Martin Renold @ 2009-07-01 16:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nanako Shiraishi, git

On Wed, Jul 01, 2009 at 01:36:03AM -0700, Junio C Hamano wrote:
> Martin Renold <martinxyz@gmx.ch> writes:
> >  git ls-files --stage > out
> >  cat > expect << EOF
> > -100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1      a1
> > +100644 439cc46de773d8a83c77799b7cc9191c128bfcff 1      a1
> >  100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2      a1
> >  100644 fd7923529855d0b274795ae3349c5e0438333979 3      a1
> >  EOF
> 
> I think Nana's patch also had this, but what is this hunk about?  IOW, why
> does stage #1 (common ancestor's version) even change?
> 
> Is this a virtual ancestor in a criss-cross recursive merge?

The file contains conflict markers, which is why it changes. I don't
understand why it has them. The merge looks pretty complex.

> But more importantly, would this new output format really as informative
> as you claim, even when the file that cannot be automerged due to its
> binaryness is not named "binary-file" but simply say "X"?  The merge.err
> output shows that there were some file that failed to merge due to being
> binary, and merge.out output owuld show that "X" had conflict.  Would it
> be just as easy for the end user to connect these two as it used to be?

You are right. With both binary and textual conflicts at the same time, the
user can not connect the two events, except by already knowing which files
are binary.

I think ideally the different pieces of information (the filename, the fact
that it has a merge conflict, and that it is binary) should be printed only
once and together.  But this goes beyond what I want to do right now.

>From an implementation point of view, the variables name1 and name2 seem to
be arbitrary, possibly user-defined conflict markers.  I think it is wrong
to print them in ll_xdl_merge() as if they were filenames.  I will try to
make a new patch that also addresses this issue.

> I for now am assuming no mechanical end user is parsing this output to
> figure out what to do, but that assumption might even be wrong.

In the rebase scenario, the mechanical end user has like 5 different places
where he could pick the filename from.  If I was writing a script I would
not expect such an output to remain stable.

bye,
Martin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH/v2] Remove filename from conflict markers
  2009-07-01 16:16         ` Martin Renold
@ 2009-07-01 20:18           ` Martin Renold
  2009-07-01 20:57             ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Martin Renold @ 2009-07-01 20:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nanako Shiraishi, git

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 <martinxyz@gmx.ch>
---

Thanks for your feedback. Here is the second attempt. It turned out that the
required function arguments were already there, just unused.

 ll-merge.c                    |    8 ++++----
 merge-recursive.c             |    9 +++++++--
 t/t3404-rebase-interactive.sh |    4 ++--
 t/t6024-recursive-merge.sh    |    9 ++++-----
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/ll-merge.c b/ll-merge.c
index 9168958..a2c13c4 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -55,7 +55,7 @@ static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
 
 static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
 			mmbuffer_t *result,
-			const char *path_unused,
+			const char *path,
 			mmfile_t *orig,
 			mmfile_t *src1, const char *name1,
 			mmfile_t *src2, const char *name2,
@@ -67,10 +67,10 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
 	if (buffer_is_binary(orig->ptr, orig->size) ||
 	    buffer_is_binary(src1->ptr, src1->size) ||
 	    buffer_is_binary(src2->ptr, src2->size)) {
-		warning("Cannot merge binary files: %s vs. %s\n",
-			name1, name2);
+		warning("Cannot merge binary files: %s (%s vs. %s)\n",
+			path, name1, name2);
 		return ll_binary_merge(drv_unused, result,
-				       path_unused,
+				       path,
 				       orig, src1, name1,
 				       src2, name2,
 				       virtual_ancestor);
diff --git a/merge-recursive.c b/merge-recursive.c
index c703445..53cad96 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -622,8 +622,13 @@ static int merge_3way(struct merge_options *o,
 	char *name1, *name2;
 	int merge_status;
 
-	name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
-	name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
+	if (strcmp(a->path, b->path)) {
+		name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
+		name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
+	} else {
+		name1 = xstrdup(mkpath("%s", branch1));
+		name2 = xstrdup(mkpath("%s", branch2));
+	}
 
 	fill_mm(one->sha1, &orig);
 	fill_mm(a->sha1, &src1);
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index c32ff66..a973628 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -119,11 +119,11 @@ index e69de29..00750ed 100644
 EOF
 
 cat > expect2 << EOF
-<<<<<<< HEAD:file1
+<<<<<<< HEAD
 2
 =======
 3
->>>>>>> b7ca976... G:file1
+>>>>>>> b7ca976... G
 EOF
 
 test_expect_success 'stop on conflicting pick' '
diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh
index 129fa30..b3fbf65 100755
--- a/t/t6024-recursive-merge.sh
+++ b/t/t6024-recursive-merge.sh
@@ -65,18 +65,18 @@ test_expect_success "combined merge conflicts" "
 "
 
 cat > expect << EOF
-<<<<<<< HEAD:a1
+<<<<<<< HEAD
 F
 =======
 G
->>>>>>> G:a1
+>>>>>>> G
 EOF
 
 test_expect_success "result contains a conflict" "test_cmp expect a1"
 
 git ls-files --stage > out
 cat > expect << EOF
-100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1	a1
+100644 439cc46de773d8a83c77799b7cc9191c128bfcff 1	a1
 100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2	a1
 100644 fd7923529855d0b274795ae3349c5e0438333979 3	a1
 EOF
@@ -93,8 +93,7 @@ test_expect_success 'refuse to merge binary files' '
 	git add binary-file &&
 	git commit -m binary2 &&
 	test_must_fail git merge F > merge.out 2> merge.err &&
-	grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \
-		merge.err
+	grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge.err
 '
 
 test_expect_success 'mark rename/delete as unmerged' '
-- 
1.6.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH/v2] Remove filename from conflict markers
  2009-07-01 20:18           ` [PATCH/v2] " Martin Renold
@ 2009-07-01 20:57             ` Junio C Hamano
  0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2009-07-01 20:57 UTC (permalink / raw)
  To: Martin Renold; +Cc: Nanako Shiraishi, git

Martin Renold <martinxyz@gmx.ch> writes:

> 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.

I think we are getting closer.

> -	grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \
> -		merge.err
> +	grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge.err

In the original code, if you are not in "merge renamed" situation, you
would see something like this.

    "Cannot merge binary files: HEAD:porn.jpg vs F:porn.jpg"

And the patch changes it to

    "Cannot merge binary files: porn.jpg (HEAD vs F)"

which is an improvement.  I have to wonder, if it even necessary to say
HEAD vs F when no rename is involved, though.  Probably it is, as this is
about binary files, and the user may need to extract the contents with
something like "git cat-file blob HEAD:porn.jpg >tmp1.jpg".

When you are indeed in "merge renamed" situation, it gets a bit more
interesting.  The original said

    "Cannot merge binary files: HEAD:porn.jpg vs F:porn112.jpg"

which makes it clear that what is merged with what, but did not say where
the resulting merge will go.  The updated output would say something like
this

    "Cannot merge binary files: porn.jpg (HEAD:porn.jpg vs F:porn112.jpg)"

which adds information and is probably better.

So overall, I like what the change does, but I'd probably wait for a few
more days just in case there are objections from different corners,
primarily because I am somewhat concerned that this change might affect
users of mergetool (which I do not use myself) in some negative way.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-07-01 20:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-28 15:45 [PATCH] Remove filename from conflict markers Martin Renold
2009-06-30 22:16 ` Junio C Hamano
2009-07-01  3:33   ` Nanako Shiraishi
2009-07-01  7:56     ` Martin Renold
2009-07-01  8:36       ` Junio C Hamano
2009-07-01 16:16         ` Martin Renold
2009-07-01 20:18           ` [PATCH/v2] " Martin Renold
2009-07-01 20:57             ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).