From 9ca8f6079cdb199851636c719900472a9745885f Mon Sep 17 00:00:00 2001
From: Junio C Hamano <gitster@pobox.com>
Date: Wed, 20 Aug 2008 15:09:28 -0700
Subject: [PATCH] "git-merge": allow fast-forwarding in a stat-dirty tree

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 deletion(-)

diff --git a/builtin-merge.c b/builtin-merge.c
index dde0c7ed33..a201c6628d 100644
--- a/builtin-merge.c
+++ b/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 a/t/t7600-merge.sh b/t/t7600-merge.sh
index 5eeb6c2b27..fee8fb77d4 100755
--- a/t/t7600-merge.sh
+++ b/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
-- 
2.48.1