summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-12-22 12:38:09 +0000
committerSean Whitton <spwhitton@spwhitton.name>2023-12-22 12:42:11 +0000
commitec7d38cff42cc793df024bccc626e69160021909 (patch)
tree17a0f335af94bf077c3dbedfb973c98cbc7de42f
parentaa873ce8cf0582a8fde06aef1d51f91ba227c423 (diff)
downloaddotfiles-ec7d38cff42cc793df024bccc626e69160021909.tar.gz
simplify git-is-clean
-rwxr-xr-xbin/git-is-clean26
1 files changed, 6 insertions, 20 deletions
diff --git a/bin/git-is-clean b/bin/git-is-clean
index 4416ac31..2b02e264 100755
--- a/bin/git-is-clean
+++ b/bin/git-is-clean
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
# find dirty working directories/staging areas/stashes
@@ -7,25 +7,11 @@
# also calling `git --no-pager log --branches --not --remotes
# --simplify-by-decoration --decorate --oneline`)
-# The git-diff-files(1) call fails in v7 git-annex repos with unlocked
-# empty files. So can't use this script in such repos.
-
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 )
+status="$(git status --porcelain -- "$@")"
+stashes="$(git stash list)"
+if ! [ -z "$status" -a -z "$stashes" ]; then
+ printf "%s\n%s\n" "$status" "$stashes"
+ exit 1
fi