Together-Java / TJ-Bot

TJ-Bot is a Discord Bot used on the Together Java server. It is maintained by the community, anyone can contribute.
https://togetherjava.org
GNU General Public License v3.0
100 stars 83 forks source link

Fix: Pre-commit hook includes untracked files in commits #1041

Closed christolis closed 4 months ago

christolis commented 4 months ago

Fixes #1039.

With this pull request, untracked files do not get included in commits handled by the pre-commit hook.

Screenshots

image image image
Zabuzard commented 4 months ago

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). @marko-radosavljevic for review please

christolis commented 4 months ago

For reference the -A option, found in the original code, works like this (source, emphasis mine):

Update the index not only where the working tree has a file matching but also where the index already has an entry. This adds, modifies, and removes index entries to match the working tree.

If no is given when -A option is used, all files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).

The -u option in the PR works like this (source, emphasis mine):

Update the index just where it already has an entry matching . This removes as well as modifies index entries to match the working tree, but adds no new files.

If no is given when -u option is used, all tracked files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).