Expand use of GIT_REPO_INFO. Foundation work for prefetch support.
This commit is contained in:
parent
0f3d16a1fa
commit
1c2393d0b3
1 changed files with 9 additions and 8 deletions
17
.bashrc
17
.bashrc
|
|
@ -24,23 +24,24 @@ __prompt_git_status() {
|
||||||
|
|
||||||
# Get some repository information.
|
# Get some repository information.
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
GIT_REPO_INFO=( $(git rev-parse --is-bare-repository --is-shallow-repository --is-inside-git-dir --is-inside-work-tree --short HEAD 2>/dev/null) )
|
GIT_REPO_INFO=( $(git rev-parse --show-toplevel --git-dir --is-bare-repository --is-shallow-repository --is-inside-git-dir --is-inside-work-tree \
|
||||||
|
--glob=prefetch 2>/dev/null) )
|
||||||
ERR="$?"
|
ERR="$?"
|
||||||
|
|
||||||
# Do nothing if there's an error.
|
# Do nothing if there's an error.
|
||||||
(( ERR >= 1 )) || { (( ERR == 128 )) && (( ${#GIT_REPO_INFO[@]} != 3 )); } && return "$RET"
|
(( ERR >= 1 )) && return "$RET"
|
||||||
|
|
||||||
# Generate the prompt.
|
# Generate the prompt.
|
||||||
if [[ "${GIT_REPO_INFO[2]}" == "true" ]]; then
|
if [[ "${GIT_REPO_INFO[4]}" == "true" ]]; then
|
||||||
# If in the git directory, use a special branch marker.
|
# If in the git directory, use a special branch marker.
|
||||||
GIT_PROMPT+="!GIT_DIR!"
|
GIT_PROMPT+="!GIT_DIR!"
|
||||||
elif [[ "${GIT_REPO_INFO[3]}" == "true" ]]; then
|
elif [[ "${GIT_REPO_INFO[5]}" == "true" ]]; then
|
||||||
# If in the working directory, generate the prompt.
|
# If in the working directory, generate the prompt.
|
||||||
# Add status markers.
|
# Add status markers.
|
||||||
[[ -n "$GIT_PROMPT_SHOW_TYPE" ]] && {
|
[[ -n "$GIT_PROMPT_SHOW_TYPE" ]] && {
|
||||||
if [[ "${GIT_REPO_INFO[0]}" == "true" ]]; then
|
if [[ "${GIT_REPO_INFO[2]}" == "true" ]]; then
|
||||||
GIT_PROMPT+="B:"
|
GIT_PROMPT+="B:"
|
||||||
elif [[ "${GIT_REPO_INFO[1]}" == "true" ]]; then
|
elif [[ "${GIT_REPO_INFO[3]}" == "true" ]]; then
|
||||||
GIT_PROMPT+="S:"
|
GIT_PROMPT+="S:"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +50,7 @@ __prompt_git_status() {
|
||||||
GIT_PROMPT+="$(git describe --contains --all HEAD)"
|
GIT_PROMPT+="$(git describe --contains --all HEAD)"
|
||||||
|
|
||||||
# Add a marker if directory is ignored, there's untracked files or a stash.
|
# Add a marker if directory is ignored, there's untracked files or a stash.
|
||||||
if [[ -n "$GIT_PROMPT_SHOW_IGNORED" ]] && git check-ignore -q "${PWD#"$(git rev-parse --show-toplevel)/"}"; then
|
if [[ -n "$GIT_PROMPT_SHOW_IGNORED" ]] && git check-ignore -q "${PWD#"${GIT_REPO_INFO[0]}/"}"; then
|
||||||
GIT_PROMPT+=" !"
|
GIT_PROMPT+=" !"
|
||||||
elif [[ -n "$GIT_PROMPT_SHOW_UNSTAGED" ]] && git ls-files --modified --exclude-standard --directory --error-unmatch -- ':/*' >/dev/null 2>&1; then
|
elif [[ -n "$GIT_PROMPT_SHOW_UNSTAGED" ]] && git ls-files --modified --exclude-standard --directory --error-unmatch -- ':/*' >/dev/null 2>&1; then
|
||||||
GIT_PROMPT+=" *"
|
GIT_PROMPT+=" *"
|
||||||
|
|
@ -63,7 +64,7 @@ __prompt_git_status() {
|
||||||
|
|
||||||
# Get upstream status.
|
# Get upstream status.
|
||||||
[[ -n "$GIT_PROMPT_SHOW_UPSTREAM" ]] || [[ -n "$GIT_PROMPT_SHOW_UPSTREAM_EXTENDED" ]] && {
|
[[ -n "$GIT_PROMPT_SHOW_UPSTREAM" ]] || [[ -n "$GIT_PROMPT_SHOW_UPSTREAM_EXTENDED" ]] && {
|
||||||
COUNT="$(git rev-list --count --left-right '@{upstream}'...HEAD 2>/dev/null | tr '[:blank:]' ' ')"
|
COUNT="$(git rev-list --count --left-right ${GIT_REPO_INFO[6]:-\'@\{upstream\}\'}...HEAD 2>/dev/null | tr '[:blank:]' ' ')"
|
||||||
case "$COUNT" in
|
case "$COUNT" in
|
||||||
"")
|
"")
|
||||||
# No upstream.
|
# No upstream.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue