-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
geometry/functions/geometry_git
Lines 62 to 85 in 0f82c56
geometry_git_conflicts() { | |
_geometry_git_guard || return | |
local _grep | |
local conflicts conflict_list | |
local file_count | |
local total raw_total | |
conflicts=$(git diff --name-only --diff-filter=U -z 2>/dev/null) | |
[[ -z "$conflicts" ]] && return | |
_grep=${GEOMETRY_GIT_GREP:=${commands[rg]:=${commands[ag]:=${commands[grep]}}}} | |
conflict_list=$($_grep -cH '^=======$' ${(0)conflicts}) | |
file_count="${(w)#conflict_list}" | |
raw_total=$(echo $conflict_list | cut -d ':' -f2 | paste -sd+ - | bc) | |
total=${raw_total##*( )} | |
[[ -z "$total" ]] && ansi ${GEOMETRY_GIT_COLOR_CONFLICTS_SOLVED:-green} ${GEOMETRY_GIT_SYMBOL_CONFLICTS_SOLVED:-"◆"} && return | |
count="(${file_count}f|${total}c)" | |
ansi ${GEOMETRY_GIT_COLOR_CONFLICTS_UNSOLVED:-red} "${GEOMETRY_GIT_SYMBOL_CONFLICTS_UNSOLVED:-'◈'} $count" | |
} |
when the list of conflicts is created with git diff
, all paths are relative from the repo root. then, the grep call on line 73 searching for the conflict symbol will grep from the CWD, which is not necessarily the repo root. this will cause the search to fail, and possibly display an error for every file that couldn't be pathed.
a simple fix would be to prefix each item in the list with git rev-parse --show-toplevel
which should return the git root.
more ideally, it might be preferable to use git diff --check
, which contains a built-in tool for detecting merge conflicts.
Metadata
Metadata
Assignees
Labels
No labels