Skip to content

Commit 1feedd0

Browse files
committed
Remove stashing logic
Using stash was problematic in the sense that suppose you commit a file and have another unstaged file to which you are making changes. During the pre-commit hook, all unstaged files are stashed, which means the unstaged file is reverted back to its original state. So, if during pre-commit linting, you try and make changes to the unstaged file, you will encounter a merge conflict once the stashed changes are restored. Furthermore, I encountered a situation where during the pre-commit hook, changes were stashed, but not restored. This seems like a recipe for dev issues. The problem certainly remains that I can try to commit a file, find that it fails lint tests, update the file to no longer fail lint tests, and fail to stage the most recent modifications. At which point, the pre-commit hook will succeed, giving me a false positive indication that everything is okay. In practice, I've found such false positives rare, as, personally, I do a decent job of staging any changes I make which are needed to pass pre-commit and pre-push checks.
1 parent 0622969 commit 1feedd0

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

tools/git/hooks/pre-commit

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,11 @@ on_error() {
6868

6969
# Runs clean-up tasks.
7070
cleanup() {
71-
# Restore stashed changes to the working tree:
72-
git stash pop -q
73-
7471
echo '' >&2
7572
}
7673

7774
# Runs initialization tasks.
7875
init() {
79-
# Stash any changes to the working tree that are not going to be committed:
80-
git stash -q --keep-index
8176
return 0
8277
}
8378

0 commit comments

Comments
 (0)