For git prompt, allow repos to disable prefetch.
This commit is contained in:
parent
4cf56beaaa
commit
fba4a7c40a
1 changed files with 5 additions and 5 deletions
8
.bashrc
8
.bashrc
|
|
@ -15,6 +15,8 @@ __prompt_git_status() {
|
||||||
# << or <x - Working tree is behind upstream (x = commits behind when used with next option).
|
# << or <x - Working tree is behind upstream (x = commits behind when used with next option).
|
||||||
# GIT_PROMPT_SHOW_UPSTREAM_EXTENDED=1 In addition to upstream status, show the number of commits difference (inplies above).
|
# GIT_PROMPT_SHOW_UPSTREAM_EXTENDED=1 In addition to upstream status, show the number of commits difference (inplies above).
|
||||||
# GIT_PROMPT_AUTO_PREFETCH=1 Automatically 'prefetch' upstream refs for comparisons (requires GIT_PROMPT_SHOW_UPSTREAM above).
|
# GIT_PROMPT_AUTO_PREFETCH=1 Automatically 'prefetch' upstream refs for comparisons (requires GIT_PROMPT_SHOW_UPSTREAM above).
|
||||||
|
# This can be disabled on a per repository basis using:
|
||||||
|
# git config --add --bool maintenance.promptprefetchdisabled true
|
||||||
# GIT_PROMPT_SHOW_IGNORED=1 Show a ! if the current directory is ignored.
|
# GIT_PROMPT_SHOW_IGNORED=1 Show a ! if the current directory is ignored.
|
||||||
# GIT_PROMPT_SHOW_UNSTAGED=1 Show a * if there are unstaged changes (superceeded by above).
|
# GIT_PROMPT_SHOW_UNSTAGED=1 Show a * if there are unstaged changes (superceeded by above).
|
||||||
# GIT_PROMPT_SHOW_UNCOMMITTED=1 Show a & if there are staged but uncommitted changes (superceeded by above).
|
# GIT_PROMPT_SHOW_UNCOMMITTED=1 Show a & if there are staged but uncommitted changes (superceeded by above).
|
||||||
|
|
@ -63,12 +65,10 @@ __prompt_git_status() {
|
||||||
# Add upstream status.
|
# Add upstream status.
|
||||||
[[ -n "$GIT_PROMPT_SHOW_UPSTREAM" ]] || [[ -n "$GIT_PROMPT_SHOW_UPSTREAM_EXTENDED" ]] && {
|
[[ -n "$GIT_PROMPT_SHOW_UPSTREAM" ]] || [[ -n "$GIT_PROMPT_SHOW_UPSTREAM_EXTENDED" ]] && {
|
||||||
# Whether to run prefetch tasks.
|
# Whether to run prefetch tasks.
|
||||||
[[ -n "$GIT_PROMPT_AUTO_PREFETCH" ]] && {
|
[[ -n "$GIT_PROMPT_AUTO_PREFETCH" ]] && [[ "$PWD" == "${GIT_REPO_INFO[0]}" ]] && \
|
||||||
# Only prefetch remotes if in the top-level working directory and if the repository is configured for maintenance work.
|
[[ "$(git config --get --bool maintenance.promptprefetchdisabled 2>/dev/null)" != "true" ]] && {
|
||||||
[[ "$PWD" == "${GIT_REPO_INFO[0]}" ]] && git config --global --get --fixed-value maintenance.repo "$PWD" >/dev/null 2>&1 && {
|
|
||||||
git maintenance run --task=prefetch 2>/dev/null || printf "\\033[1;31m%s\\033[39m\\n" "Git maintenance 'prefetch' task failed." >&2
|
git maintenance run --task=prefetch 2>/dev/null || printf "\\033[1;31m%s\\033[39m\\n" "Git maintenance 'prefetch' task failed." >&2
|
||||||
}
|
}
|
||||||
}
|
|
||||||
COUNT="$(git rev-list --count --left-right "${BRANCH:+refs/prefetch/remotes/origin/}${BRANCH:-@{upstream\}}...HEAD" 2>/dev/null | tr '[:blank:]' ' ')"
|
COUNT="$(git rev-list --count --left-right "${BRANCH:+refs/prefetch/remotes/origin/}${BRANCH:-@{upstream\}}...HEAD" 2>/dev/null | tr '[:blank:]' ' ')"
|
||||||
case "$COUNT" in
|
case "$COUNT" in
|
||||||
"")
|
"")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue