-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Summary
When a tracked text file is manually emptied (all lines deleted, file remains present on disk), gitmeup suggests removing the file with git rm and a "Remove " commit, instead of treating this as a normal modification and suggesting git add.
Environment
- OS: Ubuntu 22.04 (WSL)
- Python: 3.10
- gitmeup: 1.0.1 (installed via
pip install gitmeup) - Git: 2.x
- Repository: regular Git repo, nothing special about the file
Steps to reproduce
-
Start from a clean working tree:
git status # On branch main # nothing to commit, working tree clean
-
Open a tracked text file and delete all its contents, leaving the file empty.
Example:$ ls data/some.txt # file exists and is tracked -
Confirm Git sees it as modified, not deleted:
git status --short M data/some.txt
-
Run gitmeup:
gitmeup
Actual behaviour
gitmeup proposes to remove the file:
Proposed commands:
git rm data/some.txt
git commit -m 'chore: Remove some.txt'
When running with --apply:
+ git rm data/some.txt
error: the following file has local modifications:
data/some.txt
(use --cached to keep the file, or -f to force removal)
Command failed with exit code 1. Aborting.
Git correctly refuses to remove the file because it is a modified tracked file, not a deleted one.
If I manually stage the file:
git add data/some.txt
gitmeup --applythen gitmeup proposes a normal update commit:
Proposed commands:
git add data/some.txt
git commit -m 'chore: Emptied some.txt file'
and the resulting commit is:
1 file changed, 124 deletions(-)
rewrite data/some.txt (100%)
Expected behaviour
For a file that:
- still exists on disk, and
- is reported as
M data/some.txtingit status --short, and - has a diff consisting only of deletions,
gitmeup should:
- treat it as a modified file, and
- propose
git add data/some.txtand an "Update" commit, notgit rmand a "Remove" commit.
Only files that are actually deleted ( D path in git status --short) should be candidates for git rm.
Notes
This looks like the LLM misclassifying a "100 % deletions" diff as a file removal. A small guard based on git status --short in the executor (or a stronger instruction in the system prompt) would probably be enough to prevent git rm from ever being suggested/executed for files that Git itself still treats as modified rather than deleted.