threads / discuss / 59432

Feature Request: Allow to stash push and pop file modification times to avoid rebuilds

Subject: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds

## tl;dr

5 messages between Mar 21, 2023 and Mar 22, 2023.

replies: 4people: 3as markdown or json

Ridil culous· Mar 21, 2023, 20:46 UTC · lore
Hi

"git stash push" later followed by "git stash pop" does restore files but doesn't restore file modification times.

It would be great if there would be an option to opt in for stashing and restoring the file modification times because not restoring them potentially triggers rebuilds for many IDEs (MSVC in my case) which can be quite expensive for big projects.

Best regards ridil

rsbecker@nexbridge.com· Mar 21, 2023, 20:59 UTC · re: Ridil culous · lore

RE: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds

On Tuesday, March 21, 2023 4:47 PM, Ridil culous wrote:
Show 8 quoted lines
>"git stash push"
>later followed by
>"git stash pop"
>does restore files but doesn't restore file modification times.
>
>It would be great if there would be an option to opt in for stashing and restoring the
>file modification times because not restoring them potentially triggers rebuilds for
>many IDEs (MSVC in my case) which can be quite expensive for big projects.
IMHO, this request would break a key bit of compatibility git has with build engines that depend on timestamps. The request would cause the IDE to have false negatives during builds because the files that changed are not recognized as changing. A typical approach to do what you are requesting, where make is involved, is to use the --touch option after the stash pop to bring objects up to date - not a great plan in C++ as you can get into signature mismatches that way. Nonetheless, could you not do something like that in MSVC?
--Randall
Ridil culous· Mar 22, 2023, 11:03 UTC · re: rsbecker@nexbridge.com · lore

Re: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds

I encounter this use case many times a day and believe build consistency wouldn't be screwed for it:
- There's an existing build based on committed and uncommitted changes
- stash push the uncommitted changes
- rebase or pull
- stash pop the changes and only restore filedates for files without merges; set the current timestamp for all others
- build again

Sometimes i save and manually restore filedates from headers which are part of a precompiled header to save a quarter of an hour build time if it's not too many files. I woulnd't need this if git rebase would not refuse to rebase when there are unstaged changes like git pull does. Am i doing it wrong and there's an easier way to avoid this problem when using rebase?

Junio C Hamano· Mar 21, 2023, 21:09 UTC · re: Ridil culous · lore

Re: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds

Ridil culous <reallyridilculous@gmail.com> writes:
> "git stash push"
> later followed by
> "git stash pop"
> does restore files but doesn't restore file modification times.

It is very consistent with everything Git (the version control system) does to working tree files, e.g. "git restore -- file", "git switch branch". Like it or not, build systems that avoids recomputation of material derived from source files (which are kept in the version control systems, like Git) often work by comparing file timestamps.

Imagine that you had iffy changes in the working tree files, and then did a build. The build artifacts are based on the souce with those iffy changes. Then you do "stash push" to tentatively remove the changes. Perhaps you make a build again. You want your new build artifacts to reflect the fact that you no longer have those iffy changes in the source, so "stash push" should update the file timestamp when it removes the changes. Now you would do "stash pop", because you are convinced that those changes that you earlier thought were iffy are indeed good ones.

Now what timestamp should "stash pop" give to the working tree files in this case? The contents of the file probably is identical to the timestamp of the working tree files immediately before "stash push" was run. If we restore the original timestamp, because it is way older than the build artifacts of your second build (which was done after "stash push"), the build artifacts would not be recreated. The source has those changes (that used to be deemed iffy but now they are OK), the build artifact does not.

Unless your build system bases its rebuilding decisions on the contents, not timestamps, it is very much essential not to artificially muck with the file timestamp when your source control system rewrites the files in your working tree to avoid broken builds, I would have to say.

Ridil culous· Mar 22, 2023, 11:13 UTC · re: Junio C Hamano · lore

Re: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds

Sorry, i wrongly addressed my reply before (https://lore.kernel.org/git/20230322110309.760-1-reallyridilculous@gmail.com/) to rsbecker.
Junio C Hamano <gitster@pobox.com> wrote:
Show 6 quoted lines
> Now what timestamp should "stash pop" give to the working tree files
> in this case?  The contents of the file probably is identical to the
> timestamp of the working tree files immediately before "stash push"
> was run.  If we restore the original timestamp, because it is way
> older than the build artifacts of your second build (which was done
> after "stash push"), the build artifacts would not be recreated.
The usecase for which i'd like to have the feature would avoid that because there would be only build artefacts from the time of "stash push".

← back to recent threads