]>
Commit | Line | Data |
---|---|---|
a3e870f2 | 1 | #!/bin/sh |
ba966b95 JH |
2 | # |
3 | # Copyright (c) 2005 Linus Torvalds | |
4 | # | |
215a7ad1 | 5 | . git-sh-setup || die "Not a git archive" |
3998f8eb | 6 | |
a3e870f2 LT |
7 | report () { |
8 | header="# | |
9 | # $1: | |
10 | # ($2) | |
11 | # | |
12 | " | |
13 | trailer="" | |
14 | while read oldmode mode oldsha sha status name newname | |
15 | do | |
16 | echo -n "$header" | |
17 | header="" | |
18 | trailer="# | |
19 | " | |
20 | case "$status" in | |
2036d841 JH |
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";; | |
b55db7ba | 26 | A*) echo "# new file: $name";; |
2036d841 | 27 | U ) echo "# unmerged: $name";; |
a3e870f2 LT |
28 | esac |
29 | done | |
30 | echo -n "$trailer" | |
31 | [ "$header" ] | |
32 | } | |
33 | ||
8098a178 | 34 | branch=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD) |
9804b7dc JH |
35 | case "$branch" in |
36 | refs/heads/master) ;; | |
37 | *) echo "# On branch $branch" ;; | |
38 | esac | |
ba966b95 | 39 | |
5d1a5c02 | 40 | git-update-index -q --unmerged --refresh || exit |
ba966b95 | 41 | |
8098a178 | 42 | if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1 |
7e011c40 | 43 | then |
215a7ad1 | 44 | git-diff-index -M --cached HEAD | |
33bb218e KR |
45 | sed -e ' |
46 | s/^:// | |
47 | h | |
d52920e3 | 48 | s/^[^ ]*// |
33bb218e KR |
49 | s/ /\\ /g |
50 | x | |
d52920e3 | 51 | s/ .*$// |
33bb218e KR |
52 | G |
53 | s/\n/ /' | | |
7e011c40 | 54 | report "Updated but not checked in" "will commit" |
ba966b95 | 55 | |
7e011c40 JH |
56 | committable="$?" |
57 | else | |
58 | echo '# | |
59 | # Initial commit | |
60 | #' | |
61 | git-ls-files | | |
33bb218e KR |
62 | sed -e ' |
63 | s/ /\\ /g | |
64 | s/^/o o o o A /' | | |
7e011c40 JH |
65 | report "Updated but not checked in" "will commit" |
66 | ||
67 | committable="$?" | |
68 | fi | |
ba966b95 JH |
69 | |
70 | git-diff-files | | |
33bb218e KR |
71 | sed -e ' |
72 | s/^:// | |
73 | h | |
d52920e3 | 74 | s/^[^ ]*// |
33bb218e KR |
75 | s/ /\\ /g |
76 | x | |
d52920e3 | 77 | s/ .*$// |
33bb218e KR |
78 | G |
79 | s/\n/ /' | | |
215a7ad1 | 80 | report "Changed but not updated" "use git-update-index to mark for commit" |
ba966b95 JH |
81 | |
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\ | |
89 | #\ | |
90 | # Ignored files:\ | |
91 | # (use "git add" to add to commit)\ | |
92 | # | |
93 | s/^/# / | |
94 | $a\ | |
95 | #' | |
96 | fi | |
97 | ||
86b13da4 JH |
98 | case "$committable" in |
99 | 0) | |
a3e870f2 LT |
100 | echo "nothing to commit" |
101 | exit 1 | |
86b13da4 | 102 | esac |
a3e870f2 | 103 | exit 0 |