Skip to content

Commit

Permalink
global(git): Specify core.fsmonitor=
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Apr 6, 2023
1 parent 39fc399 commit 73f6906
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 74 deletions.
10 changes: 5 additions & 5 deletions completions/gh.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ EOF
format=${format//\p/\2}
format=${format//\o/\3}
fi
command git config --get-regexp 'remote\.[^.]*\.url' |
_omb_command_git config --get-regexp 'remote\.[^.]*\.url' |
grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' |
sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#'
}
Expand All @@ -332,12 +332,12 @@ EOF
function __hub_heads {
local i remote repo branch dir=$(__gitdir)
if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
_omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/heads/"
for i in $(__hub_github_repos); do
remote=${i%%:*}
repo=${i#*:}
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
_omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read branch; do
echo "${repo}:${branch#${remote}/}"
done
Expand All @@ -351,11 +351,11 @@ EOF
function __hub_revlist {
local i remote=${1:-origin} dir=$(__gitdir)
if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
_omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read i; do
echo "${i#${remote}/}"
done
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
_omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/tags/"
fi
}
Expand Down
10 changes: 5 additions & 5 deletions completions/hub.completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ EOF
format=${format//\p/\2}
format=${format//\o/\3}
fi
command git config --get-regexp 'remote\.[^.]*\.url' |
_omb_command_git config --get-regexp 'remote\.[^.]*\.url' |
grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' |
sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#'
}
Expand All @@ -334,12 +334,12 @@ EOF
function __hub_heads {
local i remote repo branch dir=$(__gitdir)
if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
_omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/heads/"
for i in $(__hub_github_repos); do
remote=${i%%:*}
repo=${i#*:}
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
_omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read branch; do
echo "${repo}:${branch#${remote}/}"
done
Expand All @@ -353,11 +353,11 @@ EOF
function __hub_revlist {
local i remote=${1:-origin} dir=$(__gitdir)
if [ -d "$dir" ]; then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
_omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read i; do
echo "${i#${remote}/}"
done
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
_omb_command_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/tags/"
fi
}
Expand Down
49 changes: 25 additions & 24 deletions lib/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# Outputs current branch info in prompt format

_omb_module_require lib:omb-prompt-colors
_omb_module_require lib:omb-prompt-base

# # Note: The same name of a functionis defined in omb-prompt-base. We comment
# # out this function for now.
# function git_prompt_info() {
# local ref
# if [[ "$(command git config --get oh-my-bash.hide-status 2>/dev/null)" != "1" ]]; then
# ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
# ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
# if [[ "$(_omb_command_git config --get oh-my-bash.hide-status 2>/dev/null)" != "1" ]]; then
# ref=$(_omb_command_git symbolic-ref HEAD 2> /dev/null) || \
# ref=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) || return 0
# echo "$OSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$OSH_THEME_GIT_PROMPT_SUFFIX"
# fi
# }
Expand All @@ -19,14 +20,14 @@ function parse_git_dirty() {
local STATUS=''
local FLAGS
FLAGS=('--porcelain')
if [[ "$(command git config --get oh-my-bash.hide-dirty)" != "1" ]]; then
if [[ "$(_omb_command_git config --get oh-my-bash.hide-dirty)" != "1" ]]; then
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
FLAGS+=( '--ignore-submodules=dirty' )
fi
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
FLAGS+=( '--untracked-files=no' )
fi
STATUS=$(command git status "${FLAGS[@]}" 2> /dev/null | tail -n1)
STATUS=$(_omb_command_git status "${FLAGS[@]}" 2> /dev/null | tail -n1)
fi
if [[ -n $STATUS ]]; then
echo "$OSH_THEME_GIT_PROMPT_DIRTY"
Expand All @@ -38,11 +39,11 @@ function parse_git_dirty() {
# Gets the difference between the local and remote branches
function git_remote_status() {
local remote ahead behind git_remote_status git_remote_status_detailed git_remote_origin
git_remote_origin=$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)
git_remote_origin=$(_omb_command_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)
remote=${git_remote_origin/refs\/remotes\//}
if [[ -n ${remote} ]]; then
ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
ahead=$(_omb_command_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(_omb_command_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)

if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then
git_remote_status="$OSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
Expand Down Expand Up @@ -71,20 +72,20 @@ function git_remote_status() {
# it's not a symbolic ref, but in a Git repo.
function git_current_branch() {
local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
ref=$(_omb_command_git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo.
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
ref=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
}


# Gets the number of commits ahead from remote
function git_commits_ahead() {
if command git rev-parse --git-dir &>/dev/null; then
local commits="$(command git rev-list --count @{upstream}..HEAD)"
if _omb_command_git rev-parse --git-dir &>/dev/null; then
local commits="$(_omb_command_git rev-list --count @{upstream}..HEAD)"
if [[ "$commits" != 0 ]]; then
echo "$OSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$OSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi
Expand All @@ -93,8 +94,8 @@ function git_commits_ahead() {

# Gets the number of commits behind remote
function git_commits_behind() {
if command git rev-parse --git-dir &>/dev/null; then
local commits="$(command git rev-list --count HEAD..@{upstream})"
if _omb_command_git rev-parse --git-dir &>/dev/null; then
local commits="$(_omb_command_git rev-list --count HEAD..@{upstream})"
if [[ "$commits" != 0 ]]; then
echo "$OSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$OSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
fi
Expand All @@ -103,21 +104,21 @@ function git_commits_behind() {

# Outputs if current branch is ahead of remote
function git_prompt_ahead() {
if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
if [[ -n "$(_omb_command_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
echo "$OSH_THEME_GIT_PROMPT_AHEAD"
fi
}

# Outputs if current branch is behind remote
function git_prompt_behind() {
if [[ -n "$(command git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
if [[ -n "$(_omb_command_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$OSH_THEME_GIT_PROMPT_BEHIND"
fi
}

# Outputs if current branch exists on remote or not
function git_prompt_remote() {
if [[ -n "$(command git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
if [[ -n "$(_omb_command_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$OSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
else
echo "$OSH_THEME_GIT_PROMPT_REMOTE_MISSING"
Expand All @@ -127,19 +128,19 @@ function git_prompt_remote() {
# Formats prompt string for current git commit short SHA
function git_prompt_short_sha() {
local SHA
SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER"
SHA=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) && echo "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER"
}

# Formats prompt string for current git commit long SHA
function git_prompt_long_sha() {
local SHA
SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER"
SHA=$(_omb_command_git rev-parse HEAD 2> /dev/null) && echo "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER"
}

# Get the status of the working tree
function git_prompt_status() {
local INDEX STATUS
INDEX=$(command git status --porcelain -b 2> /dev/null)
INDEX=$(_omb_command_git status --porcelain -b 2> /dev/null)
STATUS=""
if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then
STATUS="$OSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
Expand All @@ -166,7 +167,7 @@ function git_prompt_status() {
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
STATUS="$OSH_THEME_GIT_PROMPT_DELETED$STATUS"
fi
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
if $(_omb_command_git rev-parse --verify refs/stash >/dev/null 2>&1); then
STATUS="$OSH_THEME_GIT_PROMPT_STASHED$STATUS"
fi
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
Expand All @@ -190,7 +191,7 @@ function git_prompt_status() {
function git_compare_version() {
local INPUT_GIT_VERSION INSTALLED_GIT_VERSION
INPUT_GIT_VERSION=(${(s/./)1})
INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null))
INSTALLED_GIT_VERSION=($(_omb_command_git --version 2>/dev/null))
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]})

for i in {1..3}; do
Expand All @@ -209,13 +210,13 @@ function git_compare_version() {
# Outputs the name of the current user
# Usage example: $(git_current_user_name)
function git_current_user_name() {
command git config user.name 2>/dev/null
_omb_command_git config user.name 2>/dev/null
}

# Outputs the email of the current user
# Usage example: $(git_current_user_email)
function git_current_user_email() {
command git config user.email 2>/dev/null
_omb_command_git config user.email 2>/dev/null
}

# This is unlikely to change so make it all statically assigned
Expand Down
34 changes: 19 additions & 15 deletions lib/omb-prompt-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ function _omb_prompt_format {
printf -v "$1" "$__format" "$2"
}

function _omb_command_git {
command git -c core.fsmonitor= "$@"
}

function scm {
if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE
elif [[ -f .git/HEAD ]]; then SCM=$SCM_GIT
elif _omb_util_binary_exists git && [[ -n "$(command git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT
elif _omb_util_binary_exists git && [[ -n "$(_omb_command_git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT
elif [[ -d .hg ]]; then SCM=$SCM_HG
elif _omb_util_binary_exists hg && [[ -n "$(command hg root 2> /dev/null)" ]]; then SCM=$SCM_HG
elif [[ -d .svn ]]; then SCM=$SCM_SVN
Expand Down Expand Up @@ -168,7 +172,7 @@ function scm_prompt_info_common {
# This is added to address bash shell interpolation vulnerability described
# here: https://github.com/njhartwell/pw3nage
function git_clean_branch {
local unsafe_ref=$(command git symbolic-ref -q HEAD 2> /dev/null)
local unsafe_ref=$(_omb_command_git symbolic-ref -q HEAD 2> /dev/null)
local stripped_ref=${unsafe_ref##refs/heads/}
local clean_ref=${stripped_ref//[\$\`\\]/-}
clean_ref=${clean_ref//[^[:print:]]/-} # strip escape sequences, etc.
Expand All @@ -181,15 +185,15 @@ function git_prompt_minimal_info {
local git_status_flags=('--porcelain')
SCM_STATE=${SCM_THEME_PROMPT_CLEAN}

if [[ "$(command git config --get bash-it.hide-status)" != "1" ]]; then
if [[ "$(_omb_command_git config --get bash-it.hide-status)" != "1" ]]; then
# Get the branch reference
ref=$(git_clean_branch) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
ref=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) || return 0
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref}

# Get the status
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags+='-untracked-files=no'
status=$(command git status ${git_status_flags} 2> /dev/null | tail -n1)
status=$(_omb_command_git status ${git_status_flags} 2> /dev/null | tail -n1)

if [[ -n ${status} ]]; then
SCM_DIRTY=1
Expand Down Expand Up @@ -238,10 +242,10 @@ function git_prompt_vars {
local details=''
local git_status_flags=''
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
if [[ "$(command git config --get bash-it.hide-status)" != "1" ]]; then
if [[ "$(_omb_command_git config --get bash-it.hide-status)" != "1" ]]; then
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags='-uno'
local status_lines=$((command git status --porcelain ${git_status_flags} -b 2> /dev/null ||
command git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary)
local status_lines=$((_omb_command_git status --porcelain ${git_status_flags} -b 2> /dev/null ||
_omb_command_git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary)
local status=$(awk 'NR==1' <<< "$status_lines")
local counts=$(awk 'NR==2' <<< "$status_lines")
IFS=$'\t' read untracked_count unstaged_count staged_count <<< "$counts"
Expand All @@ -258,7 +262,7 @@ function git_prompt_vars {
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)"
SCM_CHANGE=$(command git rev-parse --short HEAD 2>/dev/null)
SCM_CHANGE=$(_omb_command_git rev-parse --short HEAD 2>/dev/null)
local ref=$(git_clean_branch)
Expand All @@ -272,7 +276,7 @@ function git_prompt_vars {
local remote_name=${tracking_info%%/*}
local remote_branch=${tracking_info#${remote_name}/}
local remote_info=""
local num_remotes=$(command git remote | wc -l 2> /dev/null)
local num_remotes=$(_omb_command_git remote | wc -l 2> /dev/null)
[[ "${SCM_BRANCH}" = "${remote_branch}" ]] && local same_branch_name=true
if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "${num_remotes}" -ge 2 ]]) ||
[[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then
Expand All @@ -292,11 +296,11 @@ function git_prompt_vars {
SCM_GIT_DETACHED="false"
else
local detached_prefix=""
ref=$(command git describe --tags --exact-match 2> /dev/null)
ref=$(_omb_command_git describe --tags --exact-match 2> /dev/null)
if [[ -n "$ref" ]]; then
detached_prefix=${SCM_THEME_TAG_PREFIX}
else
ref=$(command git describe --contains --all HEAD 2> /dev/null)
ref=$(_omb_command_git describe --contains --all HEAD 2> /dev/null)
ref=${ref#remotes/}
[[ -z "$ref" ]] && ref=${SCM_CHANGE}
detached_prefix=${SCM_THEME_DETACHED_PREFIX}
Expand All @@ -310,7 +314,7 @@ function git_prompt_vars {
[[ "${status}" =~ ${ahead_re} ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}"
[[ "${status}" =~ ${behind_re} ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}"
local stash_count="$(command git stash list 2> /dev/null | wc -l | tr -d ' ')"
local stash_count="$(_omb_command_git stash list 2> /dev/null | wc -l | tr -d ' ')"
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" {${stash_count}}"
SCM_BRANCH+=${details}
Expand Down Expand Up @@ -505,9 +509,9 @@ _omb_deprecate_function 20000 python_version_prompt _omb_prompt_print_python_env
function git_user_info {
# support two or more initials, set by 'git pair' plugin
SCM_CURRENT_USER=$(command git config user.initials | sed 's% %+%')
SCM_CURRENT_USER=$(_omb_command_git config user.initials | sed 's% %+%')
# if `user.initials` weren't set, attempt to extract initials from `user.name`
[[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" $(for word in $(command git config user.name | tr 'A-Z' 'a-z'); do printf "%1.1s" $word; done))
[[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" $(for word in $(_omb_command_git config user.name | tr 'A-Z' 'a-z'); do printf "%1.1s" $word; done))
[[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX"
}

Expand Down
12 changes: 6 additions & 6 deletions themes/agnoster/agnoster.theme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -327,25 +327,25 @@ function prompt_histdt {


function git_status_dirty {
dirty=$(command git status -s 2> /dev/null | tail -n 1)
dirty=$(_omb_command_git status -s 2> /dev/null | tail -n 1)
[[ -n $dirty ]] && echo ""
}

function git_stash_dirty {
stash=$(command git stash list 2> /dev/null | tail -n 1)
stash=$(_omb_command_git stash list 2> /dev/null | tail -n 1)
[[ -n $stash ]] && echo ""
}

# Git: branch/detached head, dirty status
function prompt_git {
local ref dirty
if command git rev-parse --is-inside-work-tree &>/dev/null; then
if _omb_command_git rev-parse --is-inside-work-tree &>/dev/null; then
ZSH_THEME_GIT_PROMPT_DIRTY='±'
dirty=$(git_status_dirty)
stash=$(git_stash_dirty)
ref=$(command git symbolic-ref HEAD 2> /dev/null) ||
ref="$(command git describe --exact-match --tags HEAD 2> /dev/null)" ||
ref="$(command git show-ref --head -s --abbrev | head -n1 2> /dev/null)"
ref=$(_omb_command_git symbolic-ref HEAD 2> /dev/null) ||
ref="$(_omb_command_git describe --exact-match --tags HEAD 2> /dev/null)" ||
ref="$(_omb_command_git show-ref --head -s --abbrev | head -n1 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_segment yellow black
else
Expand Down
2 changes: 1 addition & 1 deletion themes/cooperkid/cooperkid.theme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GIT_SHA_PREFIX="${_omb_prompt_navy}"
GIT_SHA_SUFFIX="${_omb_prompt_reset_color}"

function git_short_sha() {
SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX"
SHA=$(_omb_command_git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX"
}

function _omb_theme_PROMPT_COMMAND() {
Expand Down
Loading

0 comments on commit 73f6906

Please sign in to comment.