diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2017-11-25 14:06:55 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2017-11-25 14:06:55 -0700 |
commit | 3a6cf7a6ba7f4d00722054fd7e22ba99fda9766f (patch) | |
tree | 15e88ee26dc56ce57b95665cee827e53ce9fbdeb /bin/git-is-clean | |
parent | 594b16905d2ca4949d149d2ed0f1d514a03cc904 (diff) | |
download | dotfiles-3a6cf7a6ba7f4d00722054fd7e22ba99fda9766f.tar.gz |
factor out `mr isclean`
Diffstat (limited to 'bin/git-is-clean')
-rwxr-xr-x | bin/git-is-clean | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/git-is-clean b/bin/git-is-clean new file mode 100755 index 00000000..60bbe008 --- /dev/null +++ b/bin/git-is-clean @@ -0,0 +1,28 @@ +#!/bin/bash + +# find dirty working directories/staging areas/stashes + +# This is to find stuff that needs to be checked in, not stuff that +# needs to be pushed (`mr status` does a good job of the latter by +# also calling `git --no-pager log --branches --not --remotes +# --simplify-by-decoration --decorate --oneline`) + +set -e + +# we need to do something different in a direct mode annex +direct="$(git config --get annex.direct || true)" +if [ "$direct" = "true" ]; then + output="$(git annex status)" + test -z "$output" || ( echo $output && exit 1 ) +else + ( + # 1st command: check index against HEAD + # 2nd command: check working tree against index + # 3rd command: check for untracked files + # 4th command: check for stashes + git diff-index --quiet --cached HEAD \ + && git diff-files --quiet \ + && test -z "$(git status --porcelain)" \ + && test -z "$(git stash list)" + ) || ( git status --porcelain && git stash list && exit 1 ) +fi |