All of lore.kernel.org
 help / color / mirror / Atom feed
* Feature Request: Allow to stash push and pop file modification times to avoid rebuilds
@ 2023-03-21 20:46 Ridil culous
  2023-03-21 20:59 ` rsbecker
  2023-03-21 21:09 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Ridil culous @ 2023-03-21 20:46 UTC (permalink / raw)
  To: git

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

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

* RE: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds
  2023-03-21 20:46 Feature Request: Allow to stash push and pop file modification times to avoid rebuilds Ridil culous
@ 2023-03-21 20:59 ` rsbecker
  2023-03-22 11:03   ` Ridil culous
  2023-03-21 21:09 ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: rsbecker @ 2023-03-21 20:59 UTC (permalink / raw)
  To: 'Ridil culous', git

On Tuesday, March 21, 2023 4:47 PM, Ridil culous wrote:
>"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


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

* Re: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds
  2023-03-21 20:46 Feature Request: Allow to stash push and pop file modification times to avoid rebuilds Ridil culous
  2023-03-21 20:59 ` rsbecker
@ 2023-03-21 21:09 ` Junio C Hamano
  2023-03-22 11:13   ` Ridil culous
  1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2023-03-21 21:09 UTC (permalink / raw)
  To: Ridil culous; +Cc: git

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.

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

* Re: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds
  2023-03-21 20:59 ` rsbecker
@ 2023-03-22 11:03   ` Ridil culous
  0 siblings, 0 replies; 5+ messages in thread
From: Ridil culous @ 2023-03-22 11:03 UTC (permalink / raw)
  To: rsbecker; +Cc: git, reallyridilculous

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?

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

* Re: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds
  2023-03-21 21:09 ` Junio C Hamano
@ 2023-03-22 11:13   ` Ridil culous
  0 siblings, 0 replies; 5+ messages in thread
From: Ridil culous @ 2023-03-22 11:13 UTC (permalink / raw)
  To: gitster; +Cc: git, reallyridilculous

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:

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

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

end of thread, other threads:[~2023-03-22 11:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 20:46 Feature Request: Allow to stash push and pop file modification times to avoid rebuilds Ridil culous
2023-03-21 20:59 ` rsbecker
2023-03-22 11:03   ` Ridil culous
2023-03-21 21:09 ` Junio C Hamano
2023-03-22 11:13   ` Ridil culous

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.