Skip to content

Commit

Permalink
Merge branch 'jx/clean-interactive'
Browse files Browse the repository at this point in the history
Add "interactive" mode to "git clean".

The early part to refactor relative path related helper functions
looked sensible.

* jx/clean-interactive:
  test: run testcases with POSIX absolute paths on Windows
  test: add t7301 for git-clean--interactive
  git-clean: add documentation for interactive git-clean
  git-clean: add ask each interactive action
  git-clean: add select by numbers interactive action
  git-clean: add filter by pattern interactive action
  git-clean: use a git-add-interactive compatible UI
  git-clean: add colors to interactive git-clean
  git-clean: show items of del_list in columns
  git-clean: add support for -i/--interactive
  git-clean: refactor git-clean into two phases
  write_name{_quoted_relative,}(): remove redundant parameters
  quote_path_relative(): remove redundant parameter
  quote.c: substitute path_relative with relative_path
  path.c: refactor relative_path(), not only strip prefix
  test: add test cases for relative_path
  • Loading branch information
gitster committed Jul 22, 2013
2 parents c714f9f + abd4284 commit 988f98f
Show file tree
Hide file tree
Showing 14 changed files with 1,473 additions and 171 deletions.
21 changes: 13 additions & 8 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -879,16 +879,17 @@ The values of these variables may be specified as in color.branch.<slot>.

color.interactive::
When set to `always`, always use colors for interactive prompts
and displays (such as those used by "git-add --interactive").
When false (or `never`), never. When set to `true` or `auto`, use
colors only when the output is to the terminal. Defaults to false.
and displays (such as those used by "git-add --interactive" and
"git-clean --interactive"). When false (or `never`), never.
When set to `true` or `auto`, use colors only when the output is
to the terminal. Defaults to false.

color.interactive.<slot>::
Use customized color for 'git add --interactive'
output. `<slot>` may be `prompt`, `header`, `help` or `error`, for
four distinct types of normal output from interactive
commands. The values of these variables may be specified as
in color.branch.<slot>.
Use customized color for 'git add --interactive' and 'git clean
--interactive' output. `<slot>` may be `prompt`, `header`, `help`
or `error`, for four distinct types of normal output from
interactive commands. The values of these variables may be
specified as in color.branch.<slot>.

color.pager::
A boolean to enable/disable colored output when the pager is in
Expand Down Expand Up @@ -973,6 +974,10 @@ column.branch::
Specify whether to output branch listing in `git branch` in columns.
See `column.ui` for details.

column.clean::
Specify the layout when list items in `git clean -i`, which always
shows files and directories in columns. See `column.ui` for details.

column.status::
Specify whether to output untracked files in `git status` in columns.
See `column.ui` for details.
Expand Down
71 changes: 69 additions & 2 deletions Documentation/git-clean.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ git-clean - Remove untracked files from the working tree
SYNOPSIS
--------
[verse]
'git clean' [-d] [-f] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...
'git clean' [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...

DESCRIPTION
-----------
Expand All @@ -34,7 +34,13 @@ OPTIONS
-f::
--force::
If the Git configuration variable clean.requireForce is not set
to false, 'git clean' will refuse to run unless given -f or -n.
to false, 'git clean' will refuse to run unless given -f, -n or
-i.

-i::
--interactive::
Show what would be done and clean files interactively. See
``Interactive mode'' for details.

-n::
--dry-run::
Expand Down Expand Up @@ -63,6 +69,67 @@ OPTIONS
Remove only files ignored by Git. This may be useful to rebuild
everything from scratch, but keep manually created files.

Interactive mode
----------------
When the command enters the interactive mode, it shows the
files and directories to be cleaned, and goes into its
interactive command loop.

The command loop shows the list of subcommands available, and
gives a prompt "What now> ". In general, when the prompt ends
with a single '>', you can pick only one of the choices given
and type return, like this:

------------
*** Commands ***
1: clean 2: filter by pattern 3: select by numbers
4: ask each 5: quit 6: help
What now> 1
------------

You also could say `c` or `clean` above as long as the choice is unique.

The main command loop has 6 subcommands.

clean::

Start cleaning files and directories, and then quit.

filter by pattern::

This shows the files and directories to be deleted and issues an
"Input ignore patterns>>" prompt. You can input space-seperated
patterns to exclude files and directories from deletion.
E.g. "*.c *.h" will excludes files end with ".c" and ".h" from
deletion. When you are satisfied with the filtered result, press
ENTER (empty) back to the main menu.

select by numbers::

This shows the files and directories to be deleted and issues an
"Select items to delete>>" prompt. When the prompt ends with double
'>>' like this, you can make more than one selection, concatenated
with whitespace or comma. Also you can say ranges. E.g. "2-5 7,9"
to choose 2,3,4,5,7,9 from the list. If the second number in a
range is omitted, all remaining patches are taken. E.g. "7-" to
choose 7,8,9 from the list. You can say '*' to choose everything.
Also when you are satisfied with the filtered result, press ENTER
(empty) back to the main menu.

ask each::

This will start to clean, and you must confirm one by one in order
to delete items. Please note that this action is not as efficient
as the above two actions.

quit::

This lets you quit without do cleaning.

help::

Show brief usage of interactive git-clean.

SEE ALSO
--------
linkgit:gitignore[5]
Expand Down
Loading

0 comments on commit 988f98f

Please sign in to comment.