prati0100 / git-gui

Tcl/Tk based UI for Git. I am currently acting as the project's maintainer.
160 stars 87 forks source link

Allow selective staging and reverting on "added files" #5

Open prati0100 opened 4 years ago

prati0100 commented 4 years ago

Denton suggested on the list that I put my TODO list over here so other people can see it and maybe even fix them. So I'm writing some descriptions for them and adding them here.

If a file's state is "added" (IOW, it has the flag 'A'), it is not displayed as a diff. Instead, the content is shown directly. While that makes it easier to read the file (easier than reading a diff anyway), it makes it impossible to selectively stage lines using our current machinery.

So instead, show the added file as a diff and allow selective staging of lines. It would potentially hurt readability a bit since all the lines will be green and prefixed with a '+'. But its not like we do any syntax highlighting, it is probably not a huge difference. Plus, git-diff also shows added files as diffs, so most people shouldn't have a hard time adjusting.

I haven't looked too much into the problem, but my guess is that there are two major things that need to be done: display the "added file" as a diff, and then modify/remove the check in the function apply_or_revert_range_or_line that exits early if the file has a status flag other then 'M'. This check is on the line 690 in lib/diff.tcl as of writing this.