-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Infrastructure] Respect partially staged changes on pre-commit hook #30134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I might be reading it incorrectly, but it looks like this will pop from the stash list even if it didn't push onto it (because there were no unstaged changes). This will mess up the stash history and add unexpected changes to the working copy. Do you need to be checking if the push actually did something? See https://stackoverflow.com/questions/34114700/git-stash-pop-only-if-successfully-stashed-before Even so this is a bit sketchy because it works by actually changing the working copy, which will unexpectedly trigger any file watchers even though a normal |
@SteveSandersonMS this is the recommended way I read how to do it. I can't think of a different way to achieve this unless there's a way to programatically do git add to a partial hunk and we have a way to identify the hunks you have staged. |
We definitely need not to corrupt the stash history and working copy :) |
Would something like this work ?
|
@adrianwright109 I was reading about this too, seems like that's the missing piece. |
We've decided to change this to just completely skip partially staged files. We can detect these if we run MM src/.................../Program.cs |
I'm not really able to figure out the bash syntax to get this to work, if someone wants to try. $FILES and $PARTIAL have what's needed to separate partially staged files from non partially staged files. (We might also need to filter out untracked files with
|
Closing this PR for the time being |
Make sure unstaged bits of files don't get staged on partial commits
Addresses #29768