DEADSOFTWARE

Add screenshot to readme
[cavedroid.git] / require-celan-work-tree.sh
1 #!/usr/bin/env bash
3 # VonC CC BY-SA 4.0
4 # https://stackoverflow.com/a/3879077
5 # https://creativecommons.org/licenses/by-sa/4.0/
7 # Update the index
8 git update-index -q --ignore-submodules --refresh
9 err=0
11 # Disallow unstaged changes in the working tree
12 if ! git diff-files --quiet --ignore-submodules --
13 then
14 echo >&2 "cannot $1: you have unstaged changes."
15 git diff-files --name-status -r --ignore-submodules -- >&2
16 err=1
17 fi
19 # Disallow uncommitted changes in the index
20 if ! git diff-index --cached --quiet HEAD --ignore-submodules --
21 then
22 echo >&2 "cannot $1: your index contains uncommitted changes."
23 git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
24 err=1
25 fi
27 if [ $err = 1 ]
28 then
29 echo >&2 "Please commit or stash them."
30 exit 1
31 fi