From: Phillip Wood Date: Wed, 07 Oct 2026 13:49:16 GMT Subject: Re: [PATCH 1/2] stash create: remove duplicate changes detection Message-ID: <771a2364-7e5e-4d6f-be34-1764e609c514@gmail.com> In-Reply-To: On 06/10/2026 13:44, Junio C Hamano wrote: > Phillip Wood writes: > >> From: Phillip Wood >> >> Before it creates a stash, git checks if there are any unstaged, >> or uncommitted changes. If there isn't anything to stash it bails >> out. Since ef0f0b4509 (stash: optimize `get_untracked_files()` >> and `check_changes()`, 2019-02-25) "git stash store" has checked > > "store"? Aren't we talking about "create"? Sorry, it looks like I managed to confuse "create" with "store" when I wrote the message. It should be stash create: remove duplicate changes detection Before it creates a stash, git checks if there are any unstaged, or uncommitted changes. If there isn't anything to stash it bails out. Since ef0f0b4509 (stash: optimize `get_untracked_files()` and `check_changes()`, 2019-02-25) "git stash create" has checked for changes twice, once in create_stash() before we refresh the index and then again in do_create_stash() after the index has been refreshed. That commit claims it is an optimization but it is not clear what it is trying to optimize by checking for changes twice, especially as checking for changes before refreshing the index is unreliable (the scripted version of "git stash create", called "git update-index -q --refresh" before looking for any changes). Avoid checking for changes twice by removing the call to check_changes_tracked_files() from create_stash() and restore the return code handling in create_stash() that was removed by ef0f0b4509 so that we continue to exit 0 when there are no changes to stash. In principle we could remove the call to check_changes() from do_create_stash() instead, but then we'd need to pass in the list of untracked files. Thanks Phillip > >> unreliable (the scripted version of "git stash store", called "git >> update-index -q --refresh" before looking for any changes). > > Ditto. > >> Avoid checking for changes twice by removing the call to >> check_changes_tracked_files() from store_stash() and restore the return >> code handling in store_stash() that was removed by ef0f0b4509 so that >> we continue to exit 0 when there are no changes to stash. In principle >> we could remove the call to check_changes() from do_store_stash() >> instead, but then we'd need to pass in the list of untracked files. > > Again "(do_)?store" -> "\1create"?