git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: correct git merge behavior or corner case?

From
Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Date
Apr 21, 2009, 17:54 UTC
Message-ID
<20090421195434.3a01676d@gmail.com>
In-Reply-To
<alpine.DEB.1.00.0904211100350.10279@pacific.mpi-cbg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 30 quoted lines
> Hi,
> 
> On Tue, 21 Apr 2009, Johannes Schindelin wrote:
> 
> > I actually agree with Junio, though, that we want this special
> > handling of empty files only in merge-recursive.
> 
> And this _might_ be enough (not even compile-tested due to lack of
> time; the OP did not provide the test as a proper patch):
> 
> ---
> 
>  merge-recursive.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/merge-recursive.c b/merge-recursive.c
> index 774bacd..b7ea3cd 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -343,7 +343,7 @@ static struct string_list *get_renames(struct
> merge_options *o, struct string_list_item *item;
>  		struct rename *re;
>  		struct diff_filepair *pair =
> diff_queued_diff.queue[i];
> -		if (pair->status != 'R') {
> +		if (pair->status != 'R' || !re->pair->one->size) {
>  			diff_free_filepair(pair);
>  			continue;
>  		}
> --
And here is a test case:
---
 t/t6035-merge-suspected-rename.sh |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/t/t6035-merge-suspected-rename.sh b/t/t6035-merge-suspected-rename.sh
new file mode 100755
index 0000000..81615fd
--- /dev/null
+++ b/t/t6035-merge-suspected-rename.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+test_description='Merge-recursive merging suspected rename'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+	echo "hello" > date &&
+	git add date &&
+	git commit -m initial &&
+
+	git branch parallel &&
+
+	echo "hello" > LICENSE &&
+	cp LICENSE LICENSE-copy &&
+	git add LICENSE &&
+	git commit -m LICENSE &&
+
+	git rm date &&
+	git commit -m removed &&
+
+	git checkout parallel &&
+	date > date &&
+	git add date &&
+	git commit -m date
+'
+
+test_expect_success 'merge' '
+	git checkout master &&
+	test_must_fail git merge parallel &&
+	test_cmp LICENSE LICENSE-copy
+'
+
+test_done
Previous: Michał KiedrowiczNext: Jeff King
Message 14 of 17 in “correct git merge behavior or corner case?”
  1. Tuncer AyazApr 19, 2009
  2. Shawn O. PearceApr 20, 2009
  3. Johannes SchindelinApr 20, 2009
  4. Anders MelchiorsenApr 20, 2009
  5. Jeff KingApr 21, 2009
  6. Jeff KingApr 21, 2009
  7. Junio C HamanoApr 21, 2009
  8. Sverre RabbelierApr 21, 2009
  9. Johannes SchindelinApr 21, 2009
  10. Sverre RabbelierApr 21, 2009
  11. Johannes SchindelinApr 21, 2009
  12. Johannes SchindelinApr 21, 2009
  13. Michał KiedrowiczApr 21, 2009
  14. Michał KiedrowiczApr 21, 2009
  15. Jeff KingApr 21, 2009
  16. Michał KiedrowiczApr 21, 2009
  17. Jeff KingApr 21, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.