1#!/bin/sh
2#
3# Copyright (c) 2005 Linus Torvalds
4#
5. git-sh-setup || die "Not a git archive"
6
7report () {
8 header="#
9# $1:
10# ($2)
11#
12"
13 trailer=""
14 while read status name newname
15 do
16 echo -n "$header"
17 header=""
18 trailer="#
19"
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" ]
32}
33
34branch=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD)
35case "$branch" in
36refs/heads/master) ;;
37*) echo "# On branch $branch" ;;
38esac
39
40git-update-index -q --unmerged --refresh || exit
41
42if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1
43then
44 git-diff-index -M --cached --name-status --diff-filter=MDTCRA HEAD |
45 sed -e '
46 s/\\/\\\\/g
47 s/ /\\ /g
48 ' |
49 report "Updated but not checked in" "will commit"
50
51 committable="$?"
52else
53 echo '#
54# Initial commit
55#'
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"
63
64 committable="$?"
65fi
66
67git-diff-files --name-status |
68sed -e '
69 s/\\/\\\\/g
70 s/ /\\ /g
71' |
72report "Changed but not updated" "use git-update-index to mark for commit"
73
74
75if test -f "$GIT_DIR/info/exclude"
76then
77 git-ls-files -z --others \
78 --exclude-from="$GIT_DIR/info/exclude" \
79 --exclude-per-directory=.gitignore
80else
81 git-ls-files -z --others \
82 --exclude-per-directory=.gitignore
83fi |
84perl -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;
96 }
97 print "$_\n";
98 }
99'
100
101case "$committable" in
1020)
103 echo "nothing to commit"
104 exit 1
105esac
106exit 0