aboutsummaryrefslogtreecommitdiffstats
path: root/git-mergetool.sh
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2019-06-12 18:33:47 +0200
committerJunio C Hamano <gitster@pobox.com>2019-06-12 13:20:56 -0700
commit8b014655105e27d44cf62f61dd6b24322a57048f (patch)
tree3c0ebfd1c99268f879ce0b37bc049a742c88bffd /git-mergetool.sh
parente10dffd067002ea83c5293c9440adc5f23825110 (diff)
downloadgit-8b014655105e27d44cf62f61dd6b24322a57048f.tar.gz
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>
Diffstat (limited to 'git-mergetool.sh')
-rwxr-xr-xgit-mergetool.sh20
1 files changed, 11 insertions, 9 deletions
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 88fa6a914a..8a937f680f 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -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 ;;