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

[PATCH] Fix rename/copy when dealing with temporarily broken pairs.

From
Junio C Hamano <junkio@cox.net>
Date
Jun 12, 2005, 03:55 UTC
Message-ID
<7vwtp0p6tz.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vfyvpxlqi.fsf@assigned-by-dhcp.cox.net>

When rename/copy uses a file that was broken by diffcore-break as the source, and the broken filepair gets merged back later, the output was mislabeled as a rename. In this case, the source file ends up staying in the output, so we should label it as a copy instead.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 diff.c            |    1 +
 diffcore-rename.c |   10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -661,6 +661,7 @@ struct diff_filepair *diff_queue(struct 
 	dp->one = one;
 	dp->two = two;
 	dp->score = 0;
+	dp->status = 0;
 	dp->source_stays = 0;
 	dp->broken_pair = 0;
 	diff_q(queue, dp);
diff --git a/diffcore-rename.c b/diffcore-rename.c
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -249,8 +249,14 @@ void diffcore_rename(int detect_rename, 
 				continue; /* unmerged */
 			else
 				locate_rename_dst(p->two, 1);
-		else if (!DIFF_FILE_VALID(p->two))
-			register_rename_src(p->one, 0);
+		else if (!DIFF_FILE_VALID(p->two)) {
+			/* If the source is a broken "delete", and
+			 * they did not really want to get broken,
+			 * that means the source actually stays.
+			 */
+			int stays = (p->broken_pair && !p->score);
+			register_rename_src(p->one, stays);
+		}
 		else if (detect_rename == DIFF_DETECT_COPY)
 			register_rename_src(p->one, 1);
 	}
------------
Previous: Junio C HamanoNext: Jon Seymour
Message 2 of 7 in “read-tree: loosen too strict index requirements”
  1. 5/3 read-tree: loosen too strict index requirementsJunio C Hamano, Jun 11, 2005
  2. Fix rename/copy when dealing with temporarily broken pairs.Junio C Hamano, Jun 12, 2005
  3. Jon SeymourJun 13, 2005
  4. Petr BaudisJun 13, 2005
  5. Junio C HamanoJun 13, 2005
  6. Jon SeymourJun 13, 2005
  7. Add --diff-filter= output restriction to diff-* family.Junio C Hamano, Jun 12, 2005

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.