@matheusbsbs / matheus-bagliano / commits / 2b5f9a8c0c
Fork 0

git-status: do not be totally useless in a read-only repository.

This makes git-status work semi-decently in a read-only repository. Earlier, the command simply died with "cannot lock the index file" before giving any useful information to the user. Because index won't be updated in a read-only repository, stat-dirty paths appear in the "Changed but not updated" list. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Feb 22, 2007 at 00:28 UTC 2b5f9a8c0cff511f2bb0833b1ee02645b79323f4
1 file changed +11 -10
git-commit.sh
+11 -10
@@ -13,10 +13,10 @@ git-rev-parse --verify HEAD >/dev/null 2>&1 || initial_commit=t
13 case "$0" in
14 *status)
15 status_only=t
16 - unmerged_ok_if_status=--unmerged ;;
16 + ;;
17 *commit)
18 status_only=
19 - unmerged_ok_if_status= ;;
19 + ;;
20 esac
21
22 refuse_partial () {
@@ -389,16 +389,17 @@ else
389 USE_INDEX="$THIS_INDEX"
390 fi
391
392 -GIT_INDEX_FILE="$USE_INDEX" \
393 - git-update-index -q $unmerged_ok_if_status --refresh || exit
394 -
395 -################################################################
396 -# If the request is status, just show it and exit.
397 -
398 -case "$0" in
399 -*status)
392 +case "$status_only" in
393 +t)
394 + # This will silently fail in a read-only repository, which is
395 + # what we want.
396 + GIT_INDEX_FILE="$USE_INDEX" git-update-index -q --unmerged --refresh
397 run_status
398 exit $?
399 + ;;
400 +'')
401 + GIT_INDEX_FILE="$USE_INDEX" git-update-index -q --refresh || exit
402 + ;;
403 esac
404
405 ################################################################