How to make "git describe" indicate the presence or absence of local changes?

How can I check in a script if local changes are present? Perhaps combined with git describe?

+5
source share
4 answers

You need to make sure that both of the following properties are true:

  • There is no difference between HEAD and index cache

    git diff-index --cached HEAD

  • There are no differences between the index and the working tree:

    git diff-files

--quiet, ( git 1.4). git 1.4, --quiet , - .

. git diff - . .

, git_version.sh script:

git_dirty=yes
# git-1.4 does not understand "git-diff-files --quiet"
# git-1.4 does not understand "git-diff-index --cached --quiet HEAD"
if [ "x$($GIT diff-files)" = "x" ] && [ "x$($GIT diff-index --cached HEAD)" = "x" ]; then
    git_dirty=no
fi

git version >= 1.5, if git diff-files --quiet && git diff-index --quiet --cached HEAD; then .

. ( , Antony interactive git diff HEAD --quiet) HEAD. , , , , , HEAD. SHA1 git describe, , HEAD , .

+3

git 1.6.6, git-describe --dirty. , :

$ git describe --dirty
1.0.2-2-g215081f-dirty
+7

git diff --quiet 1, 0, .

, . HEAD , git diff HEAD --quiet.

--quiet --exit-code.

+1
source

git status exits with non-zero status if there are no local changes.

But I don’t understand what you mean "combined with git describe."

0
source

All Articles