]>
Commit | Line | Data |
---|---|---|
a3e870f2 | 1 | #!/bin/sh |
ba966b95 JH |
2 | # |
3 | # Copyright (c) 2005 Linus Torvalds | |
4 | # | |
d025524d FK |
5 | |
6 | USAGE='' | |
7 | SUBDIRECTORY_OK='Yes' | |
8 | ||
9 | . git-sh-setup | |
10 | ||
11 | if [ "$#" != "0" ] | |
12 | then | |
13 | usage | |
14 | fi | |
3998f8eb | 15 | |
a3e870f2 LT |
16 | report () { |
17 | header="# | |
18 | # $1: | |
19 | # ($2) | |
20 | # | |
21 | " | |
22 | trailer="" | |
71ac8356 | 23 | while read status name newname |
a3e870f2 | 24 | do |
9754563c | 25 | printf '%s' "$header" |
a3e870f2 LT |
26 | header="" |
27 | trailer="# | |
28 | " | |
29 | case "$status" in | |
2036d841 JH |
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";; | |
b55db7ba | 35 | A*) echo "# new file: $name";; |
2036d841 | 36 | U ) echo "# unmerged: $name";; |
a3e870f2 LT |
37 | esac |
38 | done | |
9754563c | 39 | printf '%s' "$trailer" |
a3e870f2 LT |
40 | [ "$header" ] |
41 | } | |
42 | ||
8098a178 | 43 | branch=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD) |
9804b7dc JH |
44 | case "$branch" in |
45 | refs/heads/master) ;; | |
46 | *) echo "# On branch $branch" ;; | |
47 | esac | |
ba966b95 | 48 | |
5d1a5c02 | 49 | git-update-index -q --unmerged --refresh || exit |
ba966b95 | 50 | |
8098a178 | 51 | if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1 |
7e011c40 | 52 | then |
f1790448 | 53 | git-diff-index -M --cached --name-status --diff-filter=MDTCRA HEAD | |
33bb218e | 54 | sed -e ' |
71ac8356 | 55 | s/\\/\\\\/g |
33bb218e | 56 | s/ /\\ /g |
71ac8356 | 57 | ' | |
7e011c40 | 58 | report "Updated but not checked in" "will commit" |
ba966b95 | 59 | |
7e011c40 JH |
60 | committable="$?" |
61 | else | |
62 | echo '# | |
63 | # Initial commit | |
64 | #' | |
65 | git-ls-files | | |
33bb218e | 66 | sed -e ' |
71ac8356 | 67 | s/\\/\\\\/g |
33bb218e | 68 | s/ /\\ /g |
71ac8356 JH |
69 | s/^/A / |
70 | ' | | |
7e011c40 JH |
71 | report "Updated but not checked in" "will commit" |
72 | ||
73 | committable="$?" | |
74 | fi | |
ba966b95 | 75 | |
71ac8356 | 76 | git-diff-files --name-status | |
33bb218e | 77 | sed -e ' |
71ac8356 | 78 | s/\\/\\\\/g |
33bb218e | 79 | s/ /\\ /g |
71ac8356 | 80 | ' | |
215a7ad1 | 81 | report "Changed but not updated" "use git-update-index to mark for commit" |
ba966b95 | 82 | |
71ac8356 JH |
83 | |
84 | if test -f "$GIT_DIR/info/exclude" | |
ba966b95 | 85 | then |
71ac8356 JH |
86 | git-ls-files -z --others \ |
87 | --exclude-from="$GIT_DIR/info/exclude" \ | |
88 | --exclude-per-directory=.gitignore | |
89 | else | |
90 | git-ls-files -z --others \ | |
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) { | |
38cc7ab8 | 102 | print "#\n# Untracked files:\n"; |
71ac8356 JH |
103 | print "# (use \"git add\" to add to commit)\n#\n"; |
104 | $shown = 1; | |
105 | } | |
106 | print "$_\n"; | |
107 | } | |
108 | ' | |
ba966b95 | 109 | |
86b13da4 JH |
110 | case "$committable" in |
111 | 0) | |
a3e870f2 LT |
112 | echo "nothing to commit" |
113 | exit 1 | |
86b13da4 | 114 | esac |
a3e870f2 | 115 | exit 0 |