Added usage strings to all commands
[guilt.git] / guilt-status
blob4f10c42a16019230194f71d1673386cf9591360d
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 source "`dirname $0`/guilt"
8 USAGE=""
10 git-rev-parse --verify HEAD >/dev/null 2>&1 || IS_INITIAL=t
12 function print_status
14 while read status name newname
16 case "$status" in
17 M ) echo "M $name";;
18 D*) echo "D $name";;
19 T ) echo "T $name";;
20 C*) echo "C $name -> $newname";;
21 R*) echo "R $name -> $newname";;
22 A*) echo "A $name";;
23 U ) echo "U $name";;
24 esac
25 done
28 # added
29 if [ -z "$IS_INITIAL" ]; then
30 # non-initial commit
31 git-diff-index -M --cached --name-status --diff-filter=MDTCRA HEAD |
32 sed -e '
33 s/\\/\\\\/g
34 s/ /\\ /g
35 ' | print_status
36 else
37 # initial commit
38 git-ls-files |
39 sed -e '
40 s/\\/\\\\/g
41 s/ /\\ /g
42 s/^/A /
43 ' | print_status
46 # untracked
47 if [ -f "$GIT_DIR/info/exclude" ]; then
48 git-ls-files -z --others \
49 --exclude-from="$GIT_DIR/info/exclude" \
50 --exclude-per-directory=.gitignore
51 else
52 git-ls-files -z --others --exclude-per-directory=.gitignore
53 fi | xargs -0 -L 1 echo | while read n; do
54 [ -z "$n" ] && continue
55 echo "$n" | sed -e 's/^/? /'
56 done