From 55abc0decf420deca5a9d1f909810f167d4230f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Skalski?= Date: Sun, 16 Oct 2022 11:21:30 +0200 Subject: [PATCH 1/2] Honour TMPDIR variable for cases when /tmp dir does not exist (i.e. on termux) Private index was tried to create in nonexistent location, no error was ever displayed, and then unconditionally GIT_INDEX_FILE variable was set pointing to nonexistent path. Git used this location and reported many changed files. It is common on Android devices - there is no /tmp directory Termux creates one and sets TMPDIR variable, which is commonly honored by most of unix utilities. Fixes issue #338 - Fixes behaviour if `/tmp` dir does not exist --- gitprompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitprompt.sh b/gitprompt.sh index 25b5bcf1..ba16aeb9 100755 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -480,7 +480,7 @@ function createPrivateIndex { else __GIT_INDEX_FILE="${GIT_INDEX_FILE}" fi - __GIT_INDEX_PRIVATE="/tmp/git-index-private$$" + __GIT_INDEX_PRIVATE="${TMPDIR:-/tmp}/git-index-private$$" command cp "${__GIT_INDEX_FILE}" "${__GIT_INDEX_PRIVATE}" 2>/dev/null echo "${__GIT_INDEX_PRIVATE}" } From 127a44a553600eca9e9376e34bf3a949d2bd0816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Skalski?= Date: Sun, 16 Oct 2022 11:29:12 +0200 Subject: [PATCH 2/2] Fixes git state 'D' was wrongly identified as 'stashed'. Additionally in case of nonexistent index file (i.e. when `/tmp` does not exist) most of files were marked with 'D' in second loop pass of `gitstatus.sh` which was wrongly identified as 'Stashed'. Now it is idenified as 'changed' --- gitstatus.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/gitstatus.sh b/gitstatus.sh index 76ffb43c..e8f921dc 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -105,7 +105,6 @@ while IFS='' read -r line || [[ -n "${line}" ]]; do AA) ((num_conflicts++)); break;; #two character matches, first loop ?M) ((num_changed++)) ;; - ?D) ((num_changed++)) ;; ?\ ) ;; #single character matches, second loop U) ((num_conflicts++)) ;;