1#!/bin/sh
2#
3# Copyright (c) 2005 Linus Torvalds
4#
5
6USAGE=''
7SUBDIRECTORY_OK='Yes'
8
9. git-sh-setup
10
11if [ "$#" != "0" ]
12then
13 usage
14fi
15
16report () {
17 header="#
18# $1:
19# ($2)
20#
21"
22 trailer=""
23 while read status name newname
24 do
25 printf '%s' "$header"
26 header=""
27 trailer="#
28"
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" ]
41}
42
43branch=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD)
44case "$branch" in
45refs/heads/master) ;;
46*) echo "# On branch $branch" ;;
47esac
48
49git-update-index -q --unmerged --refresh || exit
50
51if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1
52then
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"
59
60 committable="$?"
61else
62 echo '#
63# Initial commit
64#'
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"
72
73 committable="$?"
74fi
75
76git-diff-files --name-status |
77sed -e '
78 s/\\/\\\\/g
79 s/ /\\ /g
80' |
81report "Changed but not updated" "use git-update-index to mark for commit"
82
83
84if test -f "$GIT_DIR/info/exclude"
85then
86 git-ls-files -z --others --directory \
87 --exclude-from="$GIT_DIR/info/exclude" \
88 --exclude-per-directory=.gitignore
89else
90 git-ls-files -z --others --directory \
91 --exclude-per-directory=.gitignore
92fi |
93perl -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;
105 }
106 print "$_\n";
107 }
108'
109
110case "$committable" in
1110)
112 echo "nothing to commit"
113 exit 1
114esac
115exit 0