{"thread":{"id":"59432","subject":"Feature Request: Allow to stash push and pop file modification times to avoid rebuilds","startedAt":"2023-03-21T20:47:11Z","lastAt":"2023-03-22T11:13:50Z","messageCount":5,"participants":["Ridil culous","rsbecker@nexbridge.com","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"473882","messageId":"CAEg4PiL+Y8yxCpWaQFUswTj1qegT084w9m0rc14Kf1dEWk5G-g@mail.gmail.com","threadId":"59432","inReplyTo":null,"subject":"Feature Request: Allow to stash push and pop file modification times to avoid rebuilds","fromName":"Ridil culous","fromEmail":"reallyridilculous@gmail.com","sentAt":"2023-03-21T20:46:35Z","receivedAt":"2023-03-21T20:47:11Z","isPatch":false,"sender":{"key":"reallyridilculous@gmail.com","avatar":null},"body":"Hi\n\n\"git stash push\"\nlater followed by\n\"git stash pop\"\ndoes restore files but doesn't restore file modification times.\n\nIt would be great if there would be an option to opt in for stashing\nand restoring the file modification times because not restoring them\npotentially triggers rebuilds for many IDEs (MSVC in my case) which\ncan be quite expensive for big projects.\n\nBest regards\nridil\n"},{"id":"473884","messageId":"000a01d95c38$0acfba10$206f2e30$@nexbridge.com","threadId":"59432","inReplyTo":"CAEg4PiL+Y8yxCpWaQFUswTj1qegT084w9m0rc14Kf1dEWk5G-g@mail.gmail.com","subject":"RE: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2023-03-21T20:59:28Z","receivedAt":"2023-03-21T21:00:07Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On Tuesday, March 21, 2023 4:47 PM, Ridil culous wrote:\n>\"git stash push\"\n>later followed by\n>\"git stash pop\"\n>does restore files but doesn't restore file modification times.\n>\n>It would be great if there would be an option to opt in for stashing and restoring the\n>file modification times because not restoring them potentially triggers rebuilds for\n>many IDEs (MSVC in my case) which can be quite expensive for big projects.\n\nIMHO, 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?\n\n--Randall\n\n"},{"id":"473885","messageId":"xmqq5yathkwh.fsf@gitster.g","threadId":"59432","inReplyTo":"CAEg4PiL+Y8yxCpWaQFUswTj1qegT084w9m0rc14Kf1dEWk5G-g@mail.gmail.com","subject":"Re: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-03-21T21:09:02Z","receivedAt":"2023-03-21T21:09:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ridil culous <reallyridilculous@gmail.com> writes:\n\n> \"git stash push\"\n> later followed by\n> \"git stash pop\"\n> does restore files but doesn't restore file modification times.\n\nIt is very consistent with everything Git (the version control\nsystem) does to working tree files, e.g. \"git restore -- file\", \"git\nswitch branch\".  Like it or not, build systems that avoids\nrecomputation of material derived from source files (which are kept\nin the version control systems, like Git) often work by comparing\nfile timestamps.  \n\nImagine that you had iffy changes in the working tree files, and\nthen did a build.  The build artifacts are based on the souce with\nthose iffy changes.  Then you do \"stash push\" to tentatively remove\nthe changes.  Perhaps you make a build again.  You want your new\nbuild artifacts to reflect the fact that you no longer have those\niffy changes in the source, so \"stash push\" should update the file\ntimestamp when it removes the changes.  Now you would do \"stash\npop\", because you are convinced that those changes that you earlier\nthought were iffy are indeed good ones.\n\nNow what timestamp should \"stash pop\" give to the working tree files\nin this case?  The contents of the file probably is identical to the\ntimestamp of the working tree files immediately before \"stash push\"\nwas run.  If we restore the original timestamp, because it is way\nolder than the build artifacts of your second build (which was done\nafter \"stash push\"), the build artifacts would not be recreated.\nThe source has those changes (that used to be deemed iffy but now\nthey are OK), the build artifact does not.\n\nUnless your build system bases its rebuilding decisions on the\ncontents, not timestamps, it is very much essential not to\nartificially muck with the file timestamp when your source control\nsystem rewrites the files in your working tree to avoid broken\nbuilds, I would have to say.\n"},{"id":"473909","messageId":"20230322110309.760-1-reallyridilculous@gmail.com","threadId":"59432","inReplyTo":"000a01d95c38$0acfba10$206f2e30$@nexbridge.com","subject":"Re: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds","fromName":"Ridil culous","fromEmail":"reallyridilculous@gmail.com","sentAt":"2023-03-22T11:03:09Z","receivedAt":"2023-03-22T11:03:33Z","isPatch":false,"sender":{"key":"reallyridilculous@gmail.com","avatar":null},"body":"I encounter this use case many times a day and believe build consistency wouldn't be screwed for it:\n\n- There's an existing build based on committed and uncommitted changes\n- stash push the uncommitted changes\n- rebase or pull\n- stash pop the changes and only restore filedates for files without merges; set the current timestamp for all others\n- build again\n\nSometimes 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.\nI woulnd't need this if git rebase would not refuse to rebase when there are unstaged changes like git pull does.\nAm i doing it wrong and there's an easier way to avoid this problem when using rebase?\n"},{"id":"473910","messageId":"20230322111329.781-1-reallyridilculous@gmail.com","threadId":"59432","inReplyTo":"xmqq5yathkwh.fsf@gitster.g","subject":"Re: Feature Request: Allow to stash push and pop file modification times to avoid rebuilds","fromName":"Ridil culous","fromEmail":"reallyridilculous@gmail.com","sentAt":"2023-03-22T11:13:29Z","receivedAt":"2023-03-22T11:13:50Z","isPatch":false,"sender":{"key":"reallyridilculous@gmail.com","avatar":null},"body":"Sorry, i wrongly addressed my reply before (https://lore.kernel.org/git/20230322110309.760-1-reallyridilculous@gmail.com/) to rsbecker.\n\nJunio C Hamano <gitster@pobox.com> wrote:\n\n> Now what timestamp should \"stash pop\" give to the working tree files\n> in this case?  The contents of the file probably is identical to the\n> timestamp of the working tree files immediately before \"stash push\"\n> was run.  If we restore the original timestamp, because it is way\n> older than the build artifacts of your second build (which was done\n> after \"stash push\"), the build artifacts would not be recreated.\n\nThe 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\".\n"}]}