git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Git doesn't detect change, if file modification time is restored to original one
@ 2015-07-23  7:29 Konrád Lőrinczi
  2015-07-23  7:58 ` Sebastian Schuberth
  2015-07-23 14:17 ` Johannes Schindelin
  0 siblings, 2 replies; 7+ messages in thread
From: Konrád Lőrinczi @ 2015-07-23  7:29 UTC (permalink / raw
  To: git

I wrote a search & replace perl script, which recursively searches
files and replaces text in them. After replace, it restores original
modification time (mtime) of file.

Interesting, that git status doesn't show replaced changes, if the
mtime is same as original.

Is there a way to force git status to show changes, even if the file
dates are the same?


I tried to set core to:
    trustctime = false
    checkStat = minimal
Unfortunately the change is still not detected :(
It seems isn't a way to force fallback to file checking and completely
ignore file modification date :(


Any idea?


Thanks,
Konrad Lorinczi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Git doesn't detect change, if file modification time is restored to original one
  2015-07-23  7:29 Git doesn't detect change, if file modification time is restored to original one Konrád Lőrinczi
@ 2015-07-23  7:58 ` Sebastian Schuberth
  2015-07-23  9:14   ` Konrád Lőrinczi
  2015-07-23 14:17 ` Johannes Schindelin
  1 sibling, 1 reply; 7+ messages in thread
From: Sebastian Schuberth @ 2015-07-23  7:58 UTC (permalink / raw
  To: git

On 7/23/2015 9:29, Konrád Lőrinczi wrote:

> Interesting, that git status doesn't show replaced changes, if the
> mtime is same as original.

See the somewhat related FAQ entry at [1] and also the lengthy discussion at [2] about a similar issue. That said, deleting the .git/index file should make these files appear as modified.

[1] https://git.wiki.kernel.org/index.php/Git_FAQ#Why_isn.27t_Git_preserving_modification_time_on_files.3F
[2] https://github.com/msysgit/git/issues/312

Regards,
Sebastian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Git doesn't detect change, if file modification time is restored to original one
  2015-07-23  7:58 ` Sebastian Schuberth
@ 2015-07-23  9:14   ` Konrád Lőrinczi
  2015-07-23 14:53     ` Konstantin Khomoutov
  0 siblings, 1 reply; 7+ messages in thread
From: Konrád Lőrinczi @ 2015-07-23  9:14 UTC (permalink / raw
  To: Sebastian Schuberth; +Cc: git

Based on [1] I found some solutions which makes the changed files
appear again as changed:
a) touch -m --date=01/01/1980 .git/index
So it is a touch, but only a single one, instead of touching all the
files in the work dir.

b) git read-tree HEAD
Also working well.


I accept these solutions as workarounds, but the real solution would be:
Dev suggestions:
1) Add a --force-reread option to git status, so user can force reread tree.
git status --force-reread

2) Add status.force-reread (true or false) option to .git/config so
user can set this variable permanently for a repo.
status.force-reread = false (should be default)


Could be possible to implement 1) and 2) features to next git release?


Thanks,
Konrad Lorinczi


[1] https://github.com/msysgit/git/issues/312

2015-07-23 9:58 GMT+02:00 Sebastian Schuberth <sschuberth@gmail.com>:
> On 7/23/2015 9:29, Konrád Lőrinczi wrote:
>
>> Interesting, that git status doesn't show replaced changes, if the
>> mtime is same as original.
>
> See the somewhat related FAQ entry at [1] and also the lengthy discussion at [2] about a similar issue. That said, deleting the .git/index file should make these files appear as modified.
>
> [1] https://git.wiki.kernel.org/index.php/Git_FAQ#Why_isn.27t_Git_preserving_modification_time_on_files.3F
> [2] https://github.com/msysgit/git/issues/312
>
> Regards,
> Sebastian
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Git doesn't detect change, if file modification time is restored to original one
  2015-07-23  7:29 Git doesn't detect change, if file modification time is restored to original one Konrád Lőrinczi
  2015-07-23  7:58 ` Sebastian Schuberth
@ 2015-07-23 14:17 ` Johannes Schindelin
  1 sibling, 0 replies; 7+ messages in thread
From: Johannes Schindelin @ 2015-07-23 14:17 UTC (permalink / raw
  To: Konrád Lőrinczi; +Cc: git

Hi,

On 2015-07-23 09:29, Konrád Lőrinczi wrote:
> I wrote a search & replace perl script, which recursively searches
> files and replaces text in them. After replace, it restores original
> modification time (mtime) of file.

Since this is almost identical to https://github.com/msysgit/git/issues/312#issuecomment-124030520 I assume that you wrote that.

In my answer on the (already closed) GitHub ticket, I wrote this:

-- snipsnap --


    I wrote a search & replace perl script, which recursively searches
    files and replaces text in them. After replace, it restores original
    modification time (mtime) of file.

By this "restoring" of the original modification time you broke the contract: the mtime should reflect the time of the latest change. You replaced something, i.e. changed the file contents. Git expects the mtime to be adjusted in that case. By painstakingly faking it back to its original value you essentially told Git: don't worry, this file has not changed since you last saw it.

There is nothing Git can do to outguess you when you go out of your way to break the most fundamental promise of the mtime value.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Git doesn't detect change, if file modification time is restored to original one
  2015-07-23  9:14   ` Konrád Lőrinczi
@ 2015-07-23 14:53     ` Konstantin Khomoutov
  2015-07-23 15:16       ` Karsten Blees
  0 siblings, 1 reply; 7+ messages in thread
From: Konstantin Khomoutov @ 2015-07-23 14:53 UTC (permalink / raw
  To: Konrád Lőrinczi; +Cc: Sebastian Schuberth, git

On Thu, 23 Jul 2015 11:14:11 +0200
Konrád Lőrinczi <klorinczi@gmail.com> wrote:

[...]
> I accept these solutions as workarounds, but the real solution would
> be: Dev suggestions:
> 1) Add a --force-reread option to git status, so user can force
> reread tree. git status --force-reread
> 
> 2) Add status.force-reread (true or false) option to .git/config so
> user can set this variable permanently for a repo.
> status.force-reread = false (should be default)
> 
> Could be possible to implement 1) and 2) features to next git release?

Could you explain what's your real use case with preserving mtimes
while changing the files?  I mean, implementing "mtime-stability"
in your tools appears to be a good excersize in programming but what
real-world problem does it solve?

I'm asking because if you are not going to implement the changes to
Git you suggested yourself, then someone else should be *convinced* to
do so.  So far, your trouble appears to be too artifical to bother.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Git doesn't detect change, if file modification time is restored to original one
  2015-07-23 14:53     ` Konstantin Khomoutov
@ 2015-07-23 15:16       ` Karsten Blees
  2015-07-23 17:32         ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Karsten Blees @ 2015-07-23 15:16 UTC (permalink / raw
  To: Konstantin Khomoutov, Konrád Lőrinczi; +Cc: Sebastian Schuberth, git

Am 23.07.2015 um 16:53 schrieb Konstantin Khomoutov:
> On Thu, 23 Jul 2015 11:14:11 +0200
> Konrád Lőrinczi <klorinczi@gmail.com> wrote:
> 
> [...]
>> I accept these solutions as workarounds, but the real solution would
>> be: Dev suggestions:
>> 1) Add a --force-reread option to git status, so user can force
>> reread tree. git status --force-reread
>>
>> 2) Add status.force-reread (true or false) option to .git/config so
>> user can set this variable permanently for a repo.
>> status.force-reread = false (should be default)
>>
>> Could be possible to implement 1) and 2) features to next git release?
> 
> Could you explain what's your real use case with preserving mtimes
> while changing the files?  I mean, implementing "mtime-stability"
> in your tools appears to be a good excersize in programming but what
> real-world problem does it solve?
> 

I'd like to add that this is not a git-specific problem: resetting mtime
on purpose will fool lots of programs, including backup software, file
synchronization tools (rsync, xcopy /D), build systems (make), and web
servers / proxies (If-Modified-Since requests).

So you would typically reset mtime if you *want* programs to ignore the
changes.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Git doesn't detect change, if file modification time is restored to original one
  2015-07-23 15:16       ` Karsten Blees
@ 2015-07-23 17:32         ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2015-07-23 17:32 UTC (permalink / raw
  To: Karsten Blees
  Cc: Konstantin Khomoutov, Konrád Lőrinczi,
	Sebastian Schuberth, git

Karsten Blees <karsten.blees@gmail.com> writes:

> I'd like to add that this is not a git-specific problem: resetting mtime
> on purpose will fool lots of programs, including backup software, file
> synchronization tools (rsync, xcopy /D), build systems (make), and web
> servers / proxies (If-Modified-Since requests).
>
> So you would typically reset mtime if you *want* programs to ignore the
> changes.

Yup.  Nicely phrased.

When you run a wholesale rewrite of many files, often you find that
some (or many) of the files did not have to be modified.  E.g.
"perl -i -e 's/old/new/' *" may want to touch all files, but the
files that did not have string 'old' in them would have the same
contents as before.  In such a case, you can avoid unnecessary
reinspection of contents (e.g. recompilation) by many tools that pay
attention to mtime to see if contents changed by reverting mtime to
the original for files that did not change.

Git also pays attention to fields other than mtime, so after

    perl -i -e 's/old/ancient/' *

and reverting mtime even for ones that got changed, we should notice
the changes.  But you are correct that such an abuse of "touch" will
break many other tools.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-23 17:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-23  7:29 Git doesn't detect change, if file modification time is restored to original one Konrád Lőrinczi
2015-07-23  7:58 ` Sebastian Schuberth
2015-07-23  9:14   ` Konrád Lőrinczi
2015-07-23 14:53     ` Konstantin Khomoutov
2015-07-23 15:16       ` Karsten Blees
2015-07-23 17:32         ` Junio C Hamano
2015-07-23 14:17 ` Johannes Schindelin

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).