GIT_PROMPT_SHOW_UNTRACKED_FILES=no was not working correctly

* Fixed the bug, than GIT_SHOW_UNTRACKED_FILES=no was not respected
* Renamed GIT_SHOW_UNTRACKED_FILES to GIT_PROMPT_SHOW_UNTRACKED_FILES as
  this is more consistent to the other environment variables
* GIT_PROMPT_SHOW_UNTRACKED_FILES can be now also set on a per
  repository basis in .bash-git-rc
* Updated README

Fixes #215 and 216
master
Martin Gondermann 10 years ago
parent 2d9ec22dd2
commit 410fd059a7
  1. 9
      README.md
  2. 14
      gitprompt.sh
  3. 6
      gitstatus.sh

@ -124,7 +124,7 @@ git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt
# GIT_PROMPT_FETCH_REMOTE_STATUS=0 # uncomment to avoid fetching remote status # GIT_PROMPT_FETCH_REMOTE_STATUS=0 # uncomment to avoid fetching remote status
# GIT_PROMPT_SHOW_UPSTREAM=1 # uncomment to show upstream tracking branch # GIT_PROMPT_SHOW_UPSTREAM=1 # uncomment to show upstream tracking branch
# GIT_SHOW_UNTRACKED_FILES=all # can be no, normal or all; determines counting of untracked files # GIT_PROMPT_SHOW_UNTRACKED_FILES=all # can be no, normal or all; determines counting of untracked files
# GIT_PROMPT_STATUS_COMMAND=gitstatus_pre-1.7.10.sh # uncomment to support Git older than 1.7.10 # GIT_PROMPT_STATUS_COMMAND=gitstatus_pre-1.7.10.sh # uncomment to support Git older than 1.7.10
@ -137,7 +137,7 @@ git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt
source ~/.bash-git-prompt/gitprompt.sh source ~/.bash-git-prompt/gitprompt.sh
``` ```
You can set the `GIT_SHOW_UNTRACKED_FILES` variable to `no` or `normal` to speed things up if you have lots of You can set the `GIT_PROMPT_SHOW_UNTRACKED_FILES` variable to `no` or `normal` to speed things up if you have lots of
untracked files in your repository. This can be the case for build systems that put their build artifacts in untracked files in your repository. This can be the case for build systems that put their build artifacts in
the subdirectory structure of the git repository. the subdirectory structure of the git repository.
@ -247,6 +247,11 @@ GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # displays as ✘-1 fo
- You can also ignore a repository completely by creating a file named ``.bash-git-rc`` with the - You can also ignore a repository completely by creating a file named ``.bash-git-rc`` with the
content ``GIT_PROMPT_IGNORE=1`` in the root of your git repository. content ``GIT_PROMPT_IGNORE=1`` in the root of your git repository.
- If you have a repository with many untracked files, the git prompt can become very slow.
You can disable the display of untracked files on a per repository basis by setting
``GIT_PROMPT_SHOW_UNTRACKED_FILES=no`` in your ``.bash-git-rc`` in the repository or
by disabling it globally in your ``.bashrc``
- You can get help on the git prompt with the function ``git_prompt_help``. - You can get help on the git prompt with the function ``git_prompt_help``.
Examples are available with ``git_prompt_examples``. Examples are available with ``git_prompt_examples``.
A list of all available named colors is available with `git_prompt_color_samples` A list of all available named colors is available with `git_prompt_color_samples`

@ -332,11 +332,18 @@ function setGitPrompt() {
fi fi
unset GIT_PROMPT_IGNORE unset GIT_PROMPT_IGNORE
OLD_GIT_PROMPT_SHOW_UNTRACKED_FILES=${GIT_PROMPT_SHOW_UNTRACKED_FILES}
unset GIT_PROMPT_SHOW_UNTRACKED_FILES
if [[ -e "$repo/.bash-git-rc" ]]; then if [[ -e "$repo/.bash-git-rc" ]]; then
source "$repo/.bash-git-rc" source "$repo/.bash-git-rc"
fi fi
if [ -z "${GIT_PROMPT_SHOW_UNTRACKED_FILES}" ]; then
GIT_PROMPT_SHOW_UNTRACKED_FILES=${OLD_GIT_PROMPT_SHOW_UNTRACKED_FILES}
fi
unset OLD_GIT_PROMPT_SHOW_UNTRACKED_FILES
if [[ "$GIT_PROMPT_IGNORE" = 1 ]]; then if [[ "$GIT_PROMPT_IGNORE" = 1 ]]; then
PS1="$EMPTY_PROMPT" PS1="$EMPTY_PROMPT"
return return
@ -433,6 +440,12 @@ function updatePrompt() {
export __GIT_PROMPT_IGNORE_STASH=${GIT_PROMPT_IGNORE_STASH} export __GIT_PROMPT_IGNORE_STASH=${GIT_PROMPT_IGNORE_STASH}
export __GIT_PROMPT_SHOW_UPSTREAM=${GIT_PROMPT_SHOW_UPSTREAM} export __GIT_PROMPT_SHOW_UPSTREAM=${GIT_PROMPT_SHOW_UPSTREAM}
if [ -z "${GIT_PROMPT_SHOW_UNTRACKED_FILES}" ]; then
export __GIT_PROMPT_SHOW_UNTRACKED_FILES=all
else
export __GIT_PROMPT_SHOW_UNTRACKED_FILES=${GIT_PROMPT_SHOW_UNTRACKED_FILES}
fi
local -a git_status_fields local -a git_status_fields
git_status_fields=($("$__GIT_STATUS_CMD" 2>/dev/null)) git_status_fields=($("$__GIT_STATUS_CMD" 2>/dev/null))
@ -528,6 +541,7 @@ function gp_add_virtualenv_to_prompt {
function is_function { function is_function {
declare -Ff "$1" >/dev/null; declare -Ff "$1" >/dev/null;
} }
# Helper function that truncates $PWD depending on window width # Helper function that truncates $PWD depending on window width
function gp_truncate_pwd { function gp_truncate_pwd {
local tilde="~" local tilde="~"

@ -15,11 +15,7 @@ if [ -z "${__GIT_PROMPT_DIR}" ]; then
__GIT_PROMPT_DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )" __GIT_PROMPT_DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
fi fi
if [ -z "${GIT_SHOW_UNTRACKED_FILES}" ]; then gitstatus=$( LC_ALL=C git status --untracked-files=${__GIT_PROMPT_SHOW_UNTRACKED_FILES} --porcelain --branch )
GIT_SHOW_UNTRACKED_FILES="all"
fi
gitstatus=$( LC_ALL=C git status --untracked-files=${GIT_SHOW_UNTRACKED_FILES} --porcelain --branch )
# if the status is fatal, exit now # if the status is fatal, exit now
[[ "$?" -ne 0 ]] && exit 0 [[ "$?" -ne 0 ]] && exit 0

Loading…
Cancel
Save