]>
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="" | |
71ac8356 | 14 | while read status name newname |
a3e870f2 LT |
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 |
f1790448 | 44 | git-diff-index -M --cached --name-status --diff-filter=MDTCRA HEAD | |
33bb218e | 45 | sed -e ' |
71ac8356 | 46 | s/\\/\\\\/g |
33bb218e | 47 | s/ /\\ /g |
71ac8356 | 48 | ' | |
7e011c40 | 49 | report "Updated but not checked in" "will commit" |
ba966b95 | 50 | |
7e011c40 JH |
51 | committable="$?" |
52 | else | |
53 | echo '# | |
54 | # Initial commit | |
55 | #' | |
56 | git-ls-files | | |
33bb218e | 57 | sed -e ' |
71ac8356 | 58 | s/\\/\\\\/g |
33bb218e | 59 | s/ /\\ /g |
71ac8356 JH |
60 | s/^/A / |
61 | ' | | |
7e011c40 JH |
62 | report "Updated but not checked in" "will commit" |
63 | ||
64 | committable="$?" | |
65 | fi | |
ba966b95 | 66 | |
71ac8356 | 67 | git-diff-files --name-status | |
33bb218e | 68 | sed -e ' |
71ac8356 | 69 | s/\\/\\\\/g |
33bb218e | 70 | s/ /\\ /g |
71ac8356 | 71 | ' | |
215a7ad1 | 72 | report "Changed but not updated" "use git-update-index to mark for commit" |
ba966b95 | 73 | |
71ac8356 JH |
74 | |
75 | if test -f "$GIT_DIR/info/exclude" | |
ba966b95 | 76 | then |
71ac8356 JH |
77 | git-ls-files -z --others \ |
78 | --exclude-from="$GIT_DIR/info/exclude" \ | |
79 | --exclude-per-directory=.gitignore | |
80 | else | |
81 | git-ls-files -z --others \ | |
82 | --exclude-per-directory=.gitignore | |
83 | fi | | |
84 | perl -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) { | |
38cc7ab8 | 93 | print "#\n# Untracked files:\n"; |
71ac8356 JH |
94 | print "# (use \"git add\" to add to commit)\n#\n"; |
95 | $shown = 1; | |
96 | } | |
97 | print "$_\n"; | |
98 | } | |
99 | ' | |
ba966b95 | 100 | |
86b13da4 JH |
101 | case "$committable" in |
102 | 0) | |
a3e870f2 LT |
103 | echo "nothing to commit" |
104 | exit 1 | |
86b13da4 | 105 | esac |
a3e870f2 | 106 | exit 0 |