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

[RFC PATCH 2/2] merge-recursive: When we detect we can skip an update, actually skip it

From
Elijah Newren <newren@gmail.com>
Date
Feb 26, 2011, 18:34 UTC
Message-ID
<1298745297-25713-3-git-send-email-newren@gmail.com>
In-Reply-To
<1298745297-25713-1-git-send-email-newren@gmail.com>

In 882fd11 (merge-recursive: Delay content merging for renames 2010-09-20), the code that checked for whether we could skip updating a file in the working directory (due to the merged version matching the current copy) was moved into a separate function. In order to defer the content merging, we had to update the index with unmerged entries. As part of the move, a bug was introduced such that the message about skipping the update would be printed (if GIT_MERGE_VERBOSITY was sufficiently high) but the file would be updated in the working copy anyway.

When we detect that the file does not need to be updated in the working copy, update the index to remove the unmerged entries and then return early before updating the working copy.

STILL BROKEN: Unfortunately, this change leaves the index in a state where the renamed file is only racily clean; a 'git diff-files' will report the file as modified.

--- No Signed-off-by since it still doesn't work.

 merge-recursive.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index 16c2dbe..94b818c 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1274,9 +1274,12 @@ static int merge_content(struct merge_options *o,
 	}
 
 	if (mfi.clean && !df_conflict_remains &&
-	    sha_eq(mfi.sha, a_sha) && mfi.mode == a.mode)
+	    sha_eq(mfi.sha, a_sha) && mfi.mode == a.mode) {
 		output(o, 3, "Skipped %s (merged same as existing)", path);
-	else
+		add_cacheinfo(mfi.mode, mfi.sha, path,
+			      0, 0, ADD_CACHE_OK_TO_REPLACE);
+		return mfi.clean;
+	} else
 		output(o, 2, "Auto-merging %s", path);
 
 	if (!mfi.clean) {
-- 
1.7.4.1.23.g4865dd
Previous: Elijah NewrenNext: Elijah Newren
Message 7 of 8 in “new behaviour in git merge”
  1. Stephen RothwellFeb 24, 2011
  2. Jeff KingFeb 24, 2011
  3. Stephen RothwellFeb 24, 2011
  4. Jeff KingFeb 24, 2011
  5. 0/2 Fix unnecessary updates of files during mergeElijah Newren, Feb 26, 2011
  6. 1/2 t6022: New test checking for unnecessary updates of renamed+modified filesElijah Newren, Feb 26, 2011
  7. 2/2 merge-recursive: When we detect we can skip an update, actually skip itElijah Newren, Feb 26, 2011
  8. Elijah NewrenFeb 26, 2011

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.