]> git.ipfire.org Git - thirdparty/git.git/blame - git-status.sh
Merge branches 'jc/branch' and 'jc/rebase'
[thirdparty/git.git] / git-status.sh
CommitLineData
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
7report () {
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 34branch=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD)
9804b7dc
JH
35case "$branch" in
36refs/heads/master) ;;
37*) echo "# On branch $branch" ;;
38esac
ba966b95 39
5d1a5c02 40git-update-index -q --unmerged --refresh || exit
ba966b95 41
8098a178 42if GIT_DIR="$GIT_DIR" git-rev-parse --verify HEAD >/dev/null 2>&1
7e011c40 43then
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="$?"
52else
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="$?"
65fi
ba966b95 66
71ac8356 67git-diff-files --name-status |
33bb218e 68sed -e '
71ac8356 69 s/\\/\\\\/g
33bb218e 70 s/ /\\ /g
71ac8356 71' |
215a7ad1 72report "Changed but not updated" "use git-update-index to mark for commit"
ba966b95 73
71ac8356
JH
74
75if test -f "$GIT_DIR/info/exclude"
ba966b95 76then
71ac8356
JH
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) {
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
101case "$committable" in
1020)
a3e870f2
LT
103 echo "nothing to commit"
104 exit 1
86b13da4 105esac
a3e870f2 106exit 0