git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>, Elijah Newren <newren@gmail.com>
Subject: [PATCH v4 2/2] merge-recursive: fix the refresh logic in update_file_flags
Date: Wed, 19 Feb 2020 17:04:07 +0000	[thread overview]
Message-ID: <ba297fd67bb98bd06408241030cf42f410d5d366.1582131847.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.712.v4.git.git.1582131847.gitgitgadget@gmail.com>

From: Elijah Newren <newren@gmail.com>

If we need to delete a higher stage entry in the index to place the file
at stage 0, then we'll lose that file's stat information.  In such
situations we may still be able to detect that the file on disk is the
version we want (as noted by our comment in the code:
  /* do not overwrite file if already present */
), but we do still need to update the mtime since we are creating a new
cache_entry for that file.  Update the logic used to determine whether
we refresh a file's mtime.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-recursive.c                    | 7 +++++--
 t/t3433-rebase-across-mode-change.sh | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index aee1769a7ac..e6f943c5ccc 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -998,10 +998,13 @@ static int update_file_flags(struct merge_options *opt,
 		free(buf);
 	}
 update_index:
-	if (!ret && update_cache)
-		if (add_cacheinfo(opt, contents, path, 0, update_wd,
+	if (!ret && update_cache) {
+		int refresh = (!opt->priv->call_depth &&
+			       contents->mode != S_IFGITLINK);
+		if (add_cacheinfo(opt, contents, path, 0, refresh,
 				  ADD_CACHE_OK_TO_ADD))
 			return -1;
+	}
 	return ret;
 }
 
diff --git a/t/t3433-rebase-across-mode-change.sh b/t/t3433-rebase-across-mode-change.sh
index f11fc35c3ee..05df964670f 100755
--- a/t/t3433-rebase-across-mode-change.sh
+++ b/t/t3433-rebase-across-mode-change.sh
@@ -33,7 +33,7 @@ test_expect_success 'rebase changes with the apply backend' '
 	git rebase side1
 '
 
-test_expect_failure 'rebase changes with the merge backend' '
+test_expect_success 'rebase changes with the merge backend' '
 	test_when_finished "git rebase --abort || true" &&
 	git checkout -b merge-backend side2 &&
 	git rebase -m side1
-- 
gitgitgadget

  parent reply	other threads:[~2020-02-19 17:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 17:15 [PATCH] t3424: new rebase testcase documenting a stat-dirty-like failure Elijah Newren via GitGitGadget
2020-02-17 19:12 ` Elijah Newren
2020-02-18 15:05   ` Phillip Wood
2020-02-18 15:59     ` Elijah Newren
2020-02-19 11:01       ` Phillip Wood
2020-02-19 16:00         ` Elijah Newren
2020-02-19 16:38           ` Junio C Hamano
2020-02-19 19:33           ` Phillip Wood
2020-02-18 14:03 ` Johannes Schindelin
2020-02-18 15:55   ` Elijah Newren
2020-02-18 20:55 ` [PATCH v2] " Elijah Newren via GitGitGadget
2020-02-18 21:33   ` Junio C Hamano
2020-02-18 22:01     ` Elijah Newren
2020-02-18 22:15   ` [PATCH v3] t3433: " Elijah Newren via GitGitGadget
2020-02-19 17:04     ` [PATCH v4 0/2] " Elijah Newren via GitGitGadget
2020-02-19 17:04       ` [PATCH v4 1/2] " Elijah Newren via GitGitGadget
2020-02-19 17:04       ` Elijah Newren via GitGitGadget [this message]
2020-02-19 18:40         ` [PATCH v4 2/2] merge-recursive: fix the refresh logic in update_file_flags Junio C Hamano
2020-02-19 19:32           ` Elijah Newren
2020-02-19 21:39             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba297fd67bb98bd06408241030cf42f410d5d366.1582131847.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).