GIT 0.99.9d
[git/jnareb-git.git] / git-status.sh
blob62a24a9b03a259fa94f61b3cb060c2b99f55e40e
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 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 --name-status HEAD |
45 sed -e '
46 s/\\/\\\\/g
47 s/ /\\ /g
48 ' |
49 report "Updated but not checked in" "will commit"
51 committable="$?"
52 else
53 echo '#
54 # Initial commit
56 git-ls-files |
57 sed -e '
58 s/\\/\\\\/g
59 s/ /\\ /g
60 s/^/A /
61 ' |
62 report "Updated but not checked in" "will commit"
64 committable="$?"
67 git-diff-files --name-status |
68 sed -e '
69 s/\\/\\\\/g
70 s/ /\\ /g
71 ' |
72 report "Changed but not updated" "use git-update-index to mark for commit"
75 if test -f "$GIT_DIR/info/exclude"
76 then
77 git-ls-files -z --others \
78 --exclude-from="$GIT_DIR/info/exclude" \
79 --exclude-per-directory=.gitignore
80 else
81 git-ls-files -z --others \
82 --exclude-per-directory=.gitignore
83 fi |
84 perl -e '$/ = "\0";
85 my $shown = 0;
86 while (<>) {
87 chomp;
88 s|\\|\\\\|g;
89 s|\t|\\t|g;
90 s|\n|\\n|g;
91 s/^/# /;
92 if (!$shown) {
93 print "#\n# Untracked files:\n";
94 print "# (use \"git add\" to add to commit)\n#\n";
95 $shown = 1;
97 print "$_\n";
101 case "$committable" in
103 echo "nothing to commit"
104 exit 1
105 esac
106 exit 0