git-gui: revert untracked files by deleting them
authorJonathan Gilbert <JonathanG@iQmetrix.com>
Sun, 1 Dec 2019 02:28:33 +0000 (02:28 +0000)
committerPratyush Yadav <me@yadavpratyush.com>
Thu, 5 Dec 2019 18:42:15 +0000 (00:12 +0530)
commitfa38ab68b0ac409f695efcaa23b8bcda84defd41
tree6a1ac62bd5b56df6a8c4020c0d0ac19751ff09a4
parentd9c6469f38737e9c96428a81adf0fc4d97606bb0
git-gui: revert untracked files by deleting them

Update the revert_helper proc to check for untracked files as well as
changes, and then handle changes to be reverted and untracked files with
independent blocks of code. Prompt the user independently for untracked
files, since the underlying action is fundamentally different (rm -f).
If after deleting untracked files, the directory containing them becomes
empty, then remove the directory as well. Migrate unlocking of the index
out of _close_updateindex to a responsibility of the caller, to permit
paths that don't directly unlock the index, and refactor the error
handling added in d4e890e5 so that callers can make flow control
decisions in the event of errors. Update Tcl/Tk dependency from 8.4 to
8.6 in git-gui.sh.

A new proc delete_files takes care of actually deleting the files in
batches, using the Tcler's Wiki recommended approach for keeping the UI
responsive.

Since the checkout_index and delete_files calls are both asynchronous
and could potentially complete in any order, a "chord" is used to
coordinate unlocking the index and returning the UI to a usable state
only after both operations are complete. The `SimpleChord` class,
based on TclOO (Tcl/Tk 8.6), is added in this commit.

Signed-off-by: Jonathan Gilbert <JonathanG@iQmetrix.com>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
git-gui.sh
lib/chord.tcl [new file with mode: 0644]
lib/index.tcl