@matheusbsbs / matheus-bagliano / commits / 27c0d1c7f5
Fork 0

Migrate git-clean.sh to use git-rev-parse --parseopt.

Also minor consistency tweaks in how errors are caught. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pierre Habouzit committed Nov 4, 2007 at 11:30 UTC 27c0d1c7f51dd0b31c8a6283df7a23bdb7de8957
1 file changed +21 -18
git-clean.sh
+21 -18
@@ -3,16 +3,22 @@
3 # Copyright (c) 2005-2006 Pavel Roskin
4 #
5
6 -USAGE="[-d] [-f] [-n] [-q] [-x | -X] [--] <paths>..."
7 -LONG_USAGE='Clean untracked files from the working directory
8 - -d remove directories as well
9 - -f override clean.requireForce and clean anyway
10 - -n don'\''t remove anything, just show what would be done
11 - -q be quiet, only report errors
12 - -x remove ignored files as well
13 - -X remove only ignored files
6 +OPTIONS_KEEPDASHDASH=
7 +OPTIONS_SPEC="\
8 +git-clean [options] <paths>...
9 +
10 +Clean untracked files from the working directory
11 +
12 When optional <paths>... arguments are given, the paths
15 -affected are further limited to those that match them.'
13 +affected are further limited to those that match them.
14 +--
15 +d remove directories as well
16 +f override clean.requireForce and clean anyway
17 +n don't remove anything, just show what would be done
18 +q be quiet, only report errors
19 +x remove ignored files as well
20 +X remove only ignored files"
21 +
22 SUBDIRECTORY_OK=Yes
23 . git-sh-setup
24 require_work_tree
@@ -55,23 +61,20 @@ do
61 shift
62 break
63 ;;
58 - -*)
59 - usage
60 - ;;
64 *)
62 - break
65 + usage # should not happen
66 + ;;
67 esac
68 shift
69 done
70
71 if [ "$disabled" = true ]; then
68 - echo "clean.requireForce set and -n or -f not given; refusing to clean"
69 - exit 1
72 + die "clean.requireForce set and -n or -f not given; refusing to clean"
73 fi
74
72 -case "$ignored,$ignoredonly" in
73 - 1,1) usage;;
74 -esac
75 +if [ "$ignored,$ignoredonly" = "1,1" ]; then
76 + die "-x and -X cannot be set together"
77 +fi
78
79 if [ -z "$ignored" ]; then
80 excl="--exclude-per-directory=.gitignore"