I use git gui to select lines for being staged for a commit. This normally works like a charm. I am aware of the option to do the same on the command line.
Whenever a file does not initially have a new line at the end of the file git gui recognizes this and appends a warning message in the editor as I illustrated in the screenshot.
Problem
The problem which results from the missing line break is that one can no longer stage and commit individual lines. When I right-click to select the specific line and choose Stage line for commit from the context menu an error message pops up.
error: fatal: corrupt parch at line 11.
The problem is not specific to the operating system and can be repoduced on Windows, MacOSX and Linux. I know that I can avoid the problem if I add a new line to the file and commit this version before I continue selecting individual lines.
Steps to reproduce the problem
- Initialize a new repository.
- Create a file with three lines of content each with the word "Hallo". Do not put a new line at the end of the file.
- Add and commit the file.
- Edit the same file putting words inbetween the three lines.
- Open git gui and try to stage the changes line by line.
Request
I wonder if there is some configuration for Git which allows me to circumvent the problem. Some automatism such as a hook which adds the desired new line would also be fine.
Bug report
I sent a bug report to the Git mailing list. You can follow and participate in the discussion here.