Documentation/TODO: Mark guilt-rm as done
[guilt.git] / guilt-status
blobda1a304053aa06879aae2e30e21a7b724d32704f
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 source "`dirname $0`/guilt"
8 if [ $# -ne 0 ]; then
9 print_usage
10 exit 1
13 git-rev-parse --verify HEAD >/dev/null 2>&1 || IS_INITIAL=t
15 function print_status
17 while read status name newname
19 case "$status" in
20 M ) echo "M $name";;
21 D*) echo "D $name";;
22 T ) echo "T $name";;
23 C*) echo "C $name -> $newname";;
24 R*) echo "R $name -> $newname";;
25 A*) echo "A $name";;
26 U ) echo "U $name";;
27 esac
28 done
31 # added
32 if [ -z "$IS_INITIAL" ]; then
33 # non-initial commit
34 git-diff-index -M --cached --name-status --diff-filter=MDTCRA HEAD |
35 sed -e '
36 s/\\/\\\\/g
37 s/ /\\ /g
38 ' | print_status
39 else
40 # initial commit
41 git-ls-files |
42 sed -e '
43 s/\\/\\\\/g
44 s/ /\\ /g
45 s/^/A /
46 ' | print_status
49 # untracked
50 if [ -f "$GIT_DIR/info/exclude" ]; then
51 git-ls-files -z --others \
52 --exclude-from="$GIT_DIR/info/exclude" \
53 --exclude-per-directory=.gitignore
54 else
55 git-ls-files -z --others --exclude-per-directory=.gitignore
56 fi | xargs -0 -L 1 echo | while read n; do
57 [ -z "$n" ] && continue
58 echo "$n" | sed -e 's/^/? /'
59 done