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

"git-merge": allow fast-forwarding in a stat-dirty tree

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 20, 2008, 22:09 UTC
Message-ID
<7vljyrnxt3.fsf_-_@gitster.siamese.dyndns.org>
In-Reply-To
<EAFC48F0-5512-4A83-B9B2-44FF53319285@ai.rug.nl>

We used to refresh the index to clear stat-dirtyness before a fast-forward merge. Recent C rewrite forgot to do this.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-merge.c  |    2 +-
 t/t7600-merge.sh |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)
diff --git c/builtin-merge.c w/builtin-merge.c
index dde0c7e..a201c66 100644
--- c/builtin-merge.c
+++ w/builtin-merge.c
@@ -566,6 +566,7 @@ static int checkout_fast_forward(unsigned char *head, unsigned char *remote)
 
 	if (read_cache_unmerged())
 		die("you need to resolve your current index first");
+	refresh_cache(REFRESH_QUIET);
 
 	fd = hold_locked_index(lock_file, 1);
 
@@ -936,7 +937,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 			hex,
 			find_unique_abbrev(remoteheads->item->object.sha1,
 			DEFAULT_ABBREV));
-		refresh_cache(REFRESH_QUIET);
 		strbuf_init(&msg, 0);
 		strbuf_addstr(&msg, "Fast forward");
 		if (have_message)
diff --git c/t/t7600-merge.sh w/t/t7600-merge.sh
index 5eeb6c2..fee8fb7 100755
--- c/t/t7600-merge.sh
+++ w/t/t7600-merge.sh
@@ -488,4 +488,14 @@ test_expect_success 'merge c1 with c1 and c2' '
 
 test_debug 'gitk --all'
 
+test_expect_success 'merge fast-forward in a dirty tree' '
+       git reset --hard c0 &&
+       mv file file1 &&
+       cat file1 >file &&
+       rm -f file1 &&
+       git merge c2
+'
+
+test_debug 'gitk --all'
+
 test_done
Previous: Junio C HamanoNext: Miklos Vajna
Message 6 of 7 in “[BUG] pull faulty 'not uptodate'”
  1. Pieter de BieAug 20, 2008
  2. Junio C HamanoAug 20, 2008
  3. Pieter de BieAug 20, 2008
  4. Junio C HamanoAug 20, 2008
  5. Junio C HamanoAug 20, 2008
  6. "git-merge": allow fast-forwarding in a stat-dirty treeJunio C Hamano, Aug 20, 2008
  7. Miklos VajnaAug 20, 2008

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.