mergetool: dissect strings with shell variable magic instead of expr
git-mergetool spawns an enormous amount of processes. For this reason, the test script, t7610, is exceptionally slow, in particular, on Windows. Most of the processes are invocations of git. There are also some that can be replaced with shell builtins. Do so with `expr`. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e10dffd067
commit
8b01465510
@ -228,9 +228,8 @@ stage_submodule () {
|
||||
}
|
||||
|
||||
checkout_staged_file () {
|
||||
tmpfile=$(expr \
|
||||
"$(git checkout-index --temp --stage="$1" "$2" 2>/dev/null)" \
|
||||
: '\([^ ]*\) ')
|
||||
tmpfile="$(git checkout-index --temp --stage="$1" "$2" 2>/dev/null)" &&
|
||||
tmpfile=${tmpfile%%' '*}
|
||||
|
||||
if test $? -eq 0 && test -n "$tmpfile"
|
||||
then
|
||||
@ -255,13 +254,16 @@ merge_file () {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if BASE=$(expr "$MERGED" : '\(.*\)\.[^/]*$')
|
||||
then
|
||||
ext=$(expr "$MERGED" : '.*\(\.[^/]*\)$')
|
||||
else
|
||||
# extract file extension from the last path component
|
||||
case "${MERGED##*/}" in
|
||||
*.*)
|
||||
ext=.${MERGED##*.}
|
||||
BASE=${MERGED%"$ext"}
|
||||
;;
|
||||
*)
|
||||
BASE=$MERGED
|
||||
ext=
|
||||
fi
|
||||
esac
|
||||
|
||||
mergetool_tmpdir_init
|
||||
|
||||
@ -406,7 +408,7 @@ main () {
|
||||
-t|--tool*)
|
||||
case "$#,$1" in
|
||||
*,*=*)
|
||||
merge_tool=$(expr "z$1" : 'z-[^=]*=\(.*\)')
|
||||
merge_tool=${1#*=}
|
||||
;;
|
||||
1,*)
|
||||
usage ;;
|
||||
|
Loading…
Reference in New Issue
Block a user