git-cvsimport: Add -A <author-conv-file> option
[git/jrn.git] / git-status.sh
blob10d781c92f82197845ce30c67f796d99379e93cd
1 #!/bin/sh
3 # Copyright (c) 2005 Linus Torvalds
6 USAGE=''
7 SUBDIRECTORY_OK='Yes'
9 . git-sh-setup
11 if [ "$#" != "0" ]
12 then
13 usage
16 report () {
17 header="#
18 # $1:
19 # ($2)
22 trailer=""
23 while read status name newname
25 printf '%s' "$header"
26 header=""
27 trailer="#
29 case "$status" in
30 M ) echo "# modified: $name";;
31 D*) echo "# deleted: $name";;
32 T ) echo "# typechange: $name";;
33 C*) echo "# copied: $name -> $newname";;
34 R*) echo "# renamed: $name -> $newname";;
35 A*) echo "# new file: $name";;
36 U ) echo "# unmerged: $name";;
37 esac
38 done
39 printf '%s' "$trailer"
40 [ "$header" ]
43 branch=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD)
44 case "$branch" in
45 refs/heads/master) ;;
46 *) echo "# On branch $branch" ;;
47 esac
49 git-update-index -q --unmerged --refresh || exit
51 if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1
52 then
53 git-diff-index -M --cached --name-status --diff-filter=MDTCRA HEAD |
54 sed -e '
55 s/\\/\\\\/g
56 s/ /\\ /g
57 ' |
58 report "Updated but not checked in" "will commit"
60 committable="$?"
61 else
62 echo '#
63 # Initial commit
65 git-ls-files |
66 sed -e '
67 s/\\/\\\\/g
68 s/ /\\ /g
69 s/^/A /
70 ' |
71 report "Updated but not checked in" "will commit"
73 committable="$?"
76 git-diff-files --name-status |
77 sed -e '
78 s/\\/\\\\/g
79 s/ /\\ /g
80 ' |
81 report "Changed but not updated" "use git-update-index to mark for commit"
84 if test -f "$GIT_DIR/info/exclude"
85 then
86 git-ls-files -z --others --directory \
87 --exclude-from="$GIT_DIR/info/exclude" \
88 --exclude-per-directory=.gitignore
89 else
90 git-ls-files -z --others --directory \
91 --exclude-per-directory=.gitignore
92 fi |
93 perl -e '$/ = "\0";
94 my $shown = 0;
95 while (<>) {
96 chomp;
97 s|\\|\\\\|g;
98 s|\t|\\t|g;
99 s|\n|\\n|g;
100 s/^/# /;
101 if (!$shown) {
102 print "#\n# Untracked files:\n";
103 print "# (use \"git add\" to add to commit)\n#\n";
104 $shown = 1;
106 print "$_\n";
110 case "$committable" in
112 echo "nothing to commit"
113 exit 1
114 esac
115 exit 0