]> git.ipfire.org Git - thirdparty/git.git/blame - git-status.sh
Fix wrong filename listing bug in git-ls-tree.
[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=""
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 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
215a7ad1 44 git-diff-index -M --cached HEAD |
7e011c40
JH
45 sed 's/^://' |
46 report "Updated but not checked in" "will commit"
ba966b95 47
7e011c40
JH
48 committable="$?"
49else
50 echo '#
51# Initial commit
52#'
53 git-ls-files |
54 sed 's/^/o o o o A /' |
55 report "Updated but not checked in" "will commit"
56
57 committable="$?"
58fi
ba966b95
JH
59
60git-diff-files |
61sed 's/^://' |
215a7ad1 62report "Changed but not updated" "use git-update-index to mark for commit"
ba966b95
JH
63
64if grep -v '^#' "$GIT_DIR/info/exclude" >/dev/null 2>&1
65then
66 git-ls-files --others \
67 --exclude-from="$GIT_DIR/info/exclude" \
68 --exclude-per-directory=.gitignore |
69 sed -e '
70 1i\
71#\
72# Ignored files:\
73# (use "git add" to add to commit)\
74#
75 s/^/# /
76 $a\
77#'
78fi
79
86b13da4
JH
80case "$committable" in
810)
a3e870f2
LT
82 echo "nothing to commit"
83 exit 1
86b13da4 84esac
a3e870f2 85exit 0