From: Junio C Hamano <gitster@pobox.com>
To: Derrick Stolee <derrickstolee@github.com>
Cc: Victoria Dye via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, reichemn@icloud.com,
Victoria Dye <vdye@github.com>
Subject: Re: [PATCH v2] mv: refresh stat info for moved entry
Date: Tue, 29 Mar 2022 09:44:34 -0700 [thread overview]
Message-ID: <xmqqa6d8wvwt.fsf@gitster.g> (raw)
In-Reply-To: <5ca04e86-6c61-3d4e-88a0-a3c827e19e13@github.com> (Derrick Stolee's message of "Tue, 29 Mar 2022 09:19:29 -0400")
Derrick Stolee <derrickstolee@github.com> writes:
>> Note that the test added in 't7001-mv.sh' requires a "sleep 1" to ensure the
>> 'ctime' of the file creation will be definitively older than the 'ctime' of
>> the renamed file in 'git mv'.
>
> Unfortunate that this is necessary, but it seems to be the only way
> to handle this because of the interaction with the system clock and
> the filesystem. There are several sleeps like this in
> t1701-racy-split-index.sh, for example.
Does "test-tool chmtime" to tweak the filesystem timestamp help? I
didn't look at the specific step that uses sleep to work around.
>> +
>> + /*
>> + * Refresh the new index entry. Using 'refresh_cache_entry' ensures
>> + * we only update stat info if the entry is otherwise up-to-date (i.e.,
>> + * the contents/mode haven't changed). This ensures that we reflect the
>> + * 'ctime' of the rename in the index without (incorrectly) updating
>> + * the cached stat info to reflect unstaged changes on disk.
>> + */
>> + refreshed = refresh_cache_entry(istate, new_entry, CE_MATCH_REFRESH);
>> + if (refreshed && refreshed != new_entry) {
>> + add_index_entry(istate, refreshed, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
>> + discard_cache_entry(new_entry);
>
> I'm glad you're checking that both refreshed is non-NULL and not equal
> to new_entry. Both are possible results from refresh_cache_entry().
;-)
next prev parent reply other threads:[~2022-03-29 16:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 1:56 [PATCH] mv: refresh stat info for moved entry Victoria Dye via GitGitGadget
2022-03-25 14:31 ` Derrick Stolee
2022-03-25 22:37 ` Victoria Dye
2022-03-25 23:29 ` Junio C Hamano
2022-03-26 1:23 ` Victoria Dye
2022-03-29 1:07 ` [PATCH v2] " Victoria Dye via GitGitGadget
2022-03-29 13:19 ` Derrick Stolee
2022-03-29 16:44 ` Junio C Hamano [this message]
2022-03-29 18:54 ` Derrick Stolee
2022-03-29 19:05 ` 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=xmqqa6d8wvwt.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=reichemn@icloud.com \
--cc=vdye@github.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).