From ec7d38cff42cc793df024bccc626e69160021909 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 22 Dec 2023 12:38:09 +0000 Subject: simplify git-is-clean --- bin/git-is-clean | 26 ++++++-------------------- 1 file 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 -- cgit v1.2.3