Skip to content

pr-436/logiclrd/git-gui-revert-untracked-v1

My development environment sometimes makes automatic changes that I don't
want to keep. In some cases, this involves new files being added that I
don't want to commit or keep (but I also don't want to outright .gitignore
forever). I have typically had to explicitly delete those files externally
to Git Gui, which is a context switch to a manual operation, and I want to
be able to just select those newly-created untracked files in the UI and
"revert" them into oblivion.

This change updates the revert_helper proc to check for untracked files as
well as changes, and then changes to be reverted and untracked files are
handled by independent blocks of code. The user is prompted 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 the directory is removed as well. A new proc
delete_files takes care of actually deleting the files, using the Tcler's
Wiki recommended approach for keeping the UI responsive.

This is the second revision of this change, which differs from the first
version in the following ways:

 * The change is now based on git-gui/master.
 * With one exception, all lines are at most 80 characters long. The
   exception has a string literal in it that pushes it to 82 characters. I
   think it would be messy to try to split it, and I got advice on
   #git-devel to just let it go to 82 characters.
 * camelCase is eliminated. I eliminated it from existing code in a separate
   commit.
 * try is no longer used anywhere. The code that cares about the result (had
   code in a catch after a try) uses [catch].
 * Deletion of files and removal of empty directories is now handled by
   separate procs.
 * The deletion of a large number of files does not block the UI during its
   execution any more.
 * The revert_helper code no longer uses an epilogue of generic statements
   to be evaluated on exit.
 * When deleting files, the UI is notified about the deletion directly
   instead of doing a full rescan.

Jonathan Gilbert (2):
  git-gui: consolidate naming conventions
  git-gui: revert untracked files by deleting them

 lib/index.tcl | 343 ++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 266 insertions(+), 77 deletions(-)

base-commit: b524f6b399c77b40c8bf2b6217585fde4731472a

Submitted-As:  Message-ID: pull.436.git.1572418123.gitgitgadget@gmail.com
Assets 2