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>
This commit is contained in:
Pierre Habouzit
2007-11-04 11:30:55 +01:00
committed by Junio C Hamano
parent bac199b7b1
commit 27c0d1c7f5

View File

@ -3,16 +3,22 @@
# Copyright (c) 2005-2006 Pavel Roskin # Copyright (c) 2005-2006 Pavel Roskin
# #
USAGE="[-d] [-f] [-n] [-q] [-x | -X] [--] <paths>..." OPTIONS_KEEPDASHDASH=
LONG_USAGE='Clean untracked files from the working directory OPTIONS_SPEC="\
-d remove directories as well git-clean [options] <paths>...
-f override clean.requireForce and clean anyway
-n don'\''t remove anything, just show what would be done Clean untracked files from the working directory
-q be quiet, only report errors
-x remove ignored files as well
-X remove only ignored files
When optional <paths>... arguments are given, the paths When optional <paths>... arguments are given, the paths
affected are further limited to those that match them.' affected are further limited to those that match them.
--
d remove directories as well
f override clean.requireForce and clean anyway
n don't remove anything, just show what would be done
q be quiet, only report errors
x remove ignored files as well
X remove only ignored files"
SUBDIRECTORY_OK=Yes SUBDIRECTORY_OK=Yes
. git-sh-setup . git-sh-setup
require_work_tree require_work_tree
@ -55,23 +61,20 @@ do
shift shift
break break
;; ;;
-*)
usage
;;
*) *)
break usage # should not happen
;;
esac esac
shift shift
done done
if [ "$disabled" = true ]; then if [ "$disabled" = true ]; then
echo "clean.requireForce set and -n or -f not given; refusing to clean" die "clean.requireForce set and -n or -f not given; refusing to clean"
exit 1
fi fi
case "$ignored,$ignoredonly" in if [ "$ignored,$ignoredonly" = "1,1" ]; then
1,1) usage;; die "-x and -X cannot be set together"
esac fi
if [ -z "$ignored" ]; then if [ -z "$ignored" ]; then
excl="--exclude-per-directory=.gitignore" excl="--exclude-per-directory=.gitignore"