Teach git-status about spaces in file names also on MacOSX
[git/trast.git] / git-status.sh
blobfbdd377539eea2c4521a2df2d37ff06b80567664
1 #!/bin/sh
3 # Copyright (c) 2005 Linus Torvalds
5 . git-sh-setup || die "Not a git archive"
7 report () {
8 header="#
9 # $1:
10 # ($2)
13 trailer=""
14 while read oldmode mode oldsha sha status name newname
16 echo -n "$header"
17 header=""
18 trailer="#
20 case "$status" in
21 M ) echo "# modified: $name";;
22 D*) echo "# deleted: $name";;
23 T ) echo "# typechange: $name";;
24 C*) echo "# copied: $name -> $newname";;
25 R*) echo "# renamed: $name -> $newname";;
26 A*) echo "# new file: $name";;
27 U ) echo "# unmerged: $name";;
28 esac
29 done
30 echo -n "$trailer"
31 [ "$header" ]
34 branch=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD)
35 case "$branch" in
36 refs/heads/master) ;;
37 *) echo "# On branch $branch" ;;
38 esac
40 git-update-index -q --unmerged --refresh || exit
42 if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1
43 then
44 git-diff-index -M --cached HEAD |
45 sed -e '
46 s/^://
48 s/^[^ ]*//
49 s/ /\\ /g
51 s/ .*$//
53 s/\n/ /' |
54 report "Updated but not checked in" "will commit"
56 committable="$?"
57 else
58 echo '#
59 # Initial commit
61 git-ls-files |
62 sed -e '
63 s/ /\\ /g
64 s/^/o o o o A /' |
65 report "Updated but not checked in" "will commit"
67 committable="$?"
70 git-diff-files |
71 sed -e '
72 s/^://
74 s/^[^ ]*//
75 s/ /\\ /g
77 s/ .*$//
79 s/\n/ /' |
80 report "Changed but not updated" "use git-update-index to mark for commit"
82 if grep -v '^#' "$GIT_DIR/info/exclude" >/dev/null 2>&1
83 then
84 git-ls-files --others \
85 --exclude-from="$GIT_DIR/info/exclude" \
86 --exclude-per-directory=.gitignore |
87 sed -e '
88 1i\
90 # Ignored files:\
91 # (use "git add" to add to commit)\
93 s/^/# /
94 $a\
98 case "$committable" in
100 echo "nothing to commit"
101 exit 1
102 esac
103 exit 0