-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Fix: Pre-commit hook includes untracked files in commits #1041
Conversation
I dont quite get the point of this. Untracked files should NOT be automatically included in commits. Otherwise you can not keep files untracked, which can be on purpose (I do this quite often). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocked until I review and test it, per Daniel's request.
For reference the
The
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested and reproduced the issue. It is indeed a bug.
In my test, the following output was provided when running git status
:
On branch bug-test
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: application/src/main/java/org/togetherjava/tjbot/Application.java
Untracked files:
(use "git add <file>..." to include in what will be committed)
application/src/main/java/org/togetherjava/tjbot/BugTest.java
After running git commit -m "test"
This is the result of git status
:
On branch bug-test
nothing to commit, working tree clean
The output from the pre-commit hook shows:
****Done pre-commit hooks****
[bug-test 96a2cb1] test
2 files changed, 6 insertions(+)
create mode 100644 application/src/main/java/org/togetherjava/tjbot/BugTest.java
Clearly, we can see it's commiting untracked files.
Fixes #1039.
With this pull request, untracked files do not get included in commits handled by the pre-commit hook.
Screenshots