@matheusbsbs / matheus-bagliano / commits / 393e3b1910
Fork 0

Teach git-clean optional <paths>... parameters.

When optional paths arguments are given, git-clean passes them to underlying git-ls-files; with this, you can say: git clean 'temp-*' to clean only the garbage files whose names begin with 'temp-'. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Pavel Roskin <proski@gnu.org>

Junio C Hamano committed May 8, 2006 at 12:02 UTC 393e3b1910221da5a78f7f79a45507b5fde59b77
2 files changed +17 -5
Documentation/git-clean.txt
+4 -1
@@ -8,7 +8,7 @@ git-clean - Remove untracked files from the working tree
8 SYNOPSIS
9 --------
10 [verse]
11 -'git-clean' [-d] [-n] [-q] [-x | -X]
11 +'git-clean' [-d] [-n] [-q] [-x | -X] [--] <paths>...
12
13 DESCRIPTION
14 -----------
@@ -16,6 +16,9 @@ Removes files unknown to git. This allows to clean the working tree
16 from files that are not under version control. If the '-x' option is
17 specified, ignored files are also removed, allowing to remove all
18 build products.
19 +When optional `<paths>...` arguments are given, the paths
20 +affected are further limited to those that match them.
21 +
22
23 OPTIONS
24 -------
git-clean.sh
+13 -4
@@ -3,13 +3,15 @@
3 # Copyright (c) 2005-2006 Pavel Roskin
4 #
5
6 -USAGE="[-d] [-n] [-q] [-x | -X]"
6 +USAGE="[-d] [-n] [-q] [-x | -X] [--] <paths>..."
7 LONG_USAGE='Clean untracked files from the working directory
8 -d remove directories as well
9 -n don'\''t remove anything, just show what would be done
10 -q be quiet, only report errors
11 -x remove ignored files as well
12 - -X remove only ignored files as well'
12 + -X remove only ignored files
13 +When optional <paths>... arguments are given, the paths
14 +affected are further limited to those that match them.'
15 SUBDIRECTORY_OK=Yes
16 . git-sh-setup
17
@@ -44,8 +46,15 @@ do
46 -X)
47 ignoredonly=1
48 ;;
47 - *)
49 + --)
50 + shift
51 + break
52 + ;;
53 + -*)
54 usage
55 + ;;
56 + *)
57 + break
58 esac
59 shift
60 done
@@ -64,7 +73,7 @@ if [ -z "$ignored" ]; then
73 fi
74 fi
75
67 -git-ls-files --others --directory $excl ${excl_info:+"$excl_info"} |
76 +git-ls-files --others --directory $excl ${excl_info:+"$excl_info"} -- "$@" |
77 while read -r file; do
78 if [ -d "$file" -a ! -L "$file" ]; then
79 if [ -z "$cleandir" ]; then