Skip to content

Commit 988f98f

Browse files
committed
Merge branch 'jx/clean-interactive'
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
2 parents c714f9f + abd4284 commit 988f98f

File tree

14 files changed

+1473
-171
lines changed

14 files changed

+1473
-171
lines changed

Documentation/config.txt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -879,16 +879,17 @@ The values of these variables may be specified as in color.branch.<slot>.
879879

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

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

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

977+
column.clean::
978+
Specify the layout when list items in `git clean -i`, which always
979+
shows files and directories in columns. See `column.ui` for details.
980+
976981
column.status::
977982
Specify whether to output untracked files in `git status` in columns.
978983
See `column.ui` for details.

Documentation/git-clean.txt

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-clean - Remove untracked files from the working tree
88
SYNOPSIS
99
--------
1010
[verse]
11-
'git clean' [-d] [-f] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...
11+
'git clean' [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...
1212

1313
DESCRIPTION
1414
-----------
@@ -34,7 +34,13 @@ OPTIONS
3434
-f::
3535
--force::
3636
If the Git configuration variable clean.requireForce is not set
37-
to false, 'git clean' will refuse to run unless given -f or -n.
37+
to false, 'git clean' will refuse to run unless given -f, -n or
38+
-i.
39+
40+
-i::
41+
--interactive::
42+
Show what would be done and clean files interactively. See
43+
``Interactive mode'' for details.
3844

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

72+
Interactive mode
73+
----------------
74+
When the command enters the interactive mode, it shows the
75+
files and directories to be cleaned, and goes into its
76+
interactive command loop.
77+
78+
The command loop shows the list of subcommands available, and
79+
gives a prompt "What now> ". In general, when the prompt ends
80+
with a single '>', you can pick only one of the choices given
81+
and type return, like this:
82+
83+
------------
84+
*** Commands ***
85+
1: clean 2: filter by pattern 3: select by numbers
86+
4: ask each 5: quit 6: help
87+
What now> 1
88+
------------
89+
90+
You also could say `c` or `clean` above as long as the choice is unique.
91+
92+
The main command loop has 6 subcommands.
93+
94+
clean::
95+
96+
Start cleaning files and directories, and then quit.
97+
98+
filter by pattern::
99+
100+
This shows the files and directories to be deleted and issues an
101+
"Input ignore patterns>>" prompt. You can input space-seperated
102+
patterns to exclude files and directories from deletion.
103+
E.g. "*.c *.h" will excludes files end with ".c" and ".h" from
104+
deletion. When you are satisfied with the filtered result, press
105+
ENTER (empty) back to the main menu.
106+
107+
select by numbers::
108+
109+
This shows the files and directories to be deleted and issues an
110+
"Select items to delete>>" prompt. When the prompt ends with double
111+
'>>' like this, you can make more than one selection, concatenated
112+
with whitespace or comma. Also you can say ranges. E.g. "2-5 7,9"
113+
to choose 2,3,4,5,7,9 from the list. If the second number in a
114+
range is omitted, all remaining patches are taken. E.g. "7-" to
115+
choose 7,8,9 from the list. You can say '*' to choose everything.
116+
Also when you are satisfied with the filtered result, press ENTER
117+
(empty) back to the main menu.
118+
119+
ask each::
120+
121+
This will start to clean, and you must confirm one by one in order
122+
to delete items. Please note that this action is not as efficient
123+
as the above two actions.
124+
125+
quit::
126+
127+
This lets you quit without do cleaning.
128+
129+
help::
130+
131+
Show brief usage of interactive git-clean.
132+
66133
SEE ALSO
67134
--------
68135
linkgit:gitignore[5]

0 commit comments

Comments
 (0)