Merge branch 'da/difftool-mergetool-simplify-reporting-status'

Code simplification.

* da/difftool-mergetool-simplify-reporting-status:
  mergetools: stop setting $status in merge_cmd()
  mergetool: simplify conditionals
  difftool--helper: add explicit exit statement
  mergetool--lib: remove use of $status global
  mergetool--lib: remove no-op assignment to $status from setup_user_tool
This commit is contained in:
Junio C Hamano 2014-12-12 14:31:39 -08:00
commit 0ddedd4d6b
6 changed files with 12 additions and 29 deletions

View File

@ -94,3 +94,5 @@ else
shift 7
done
fi
exit 0

View File

@ -92,7 +92,7 @@ translate_merge_tool_path () {
check_unchanged () {
if test "$MERGED" -nt "$BACKUP"
then
status=0
return 0
else
while true
do
@ -100,8 +100,8 @@ check_unchanged () {
printf "Was the merge successful? [y/n] "
read answer || return 1
case "$answer" in
y*|Y*) status=0; break ;;
n*|N*) status=1; break ;;
y*|Y*) return 0 ;;
n*|N*) return 1 ;;
esac
done
fi
@ -119,8 +119,6 @@ setup_user_tool () {
diff_cmd () {
( eval $merge_tool_cmd )
status=$?
return $status
}
merge_cmd () {
@ -130,13 +128,10 @@ setup_user_tool () {
then
touch "$BACKUP"
( eval $merge_tool_cmd )
status=$?
check_unchanged
else
( eval $merge_tool_cmd )
status=$?
fi
return $status
}
}
@ -153,13 +148,11 @@ setup_tool () {
}
diff_cmd () {
status=1
return $status
return 1
}
merge_cmd () {
status=1
return $status
return 1
}
translate_merge_tool_path () {
@ -210,7 +203,6 @@ run_merge_tool () {
merge_tool_path=$(get_merge_tool_path "$1") || exit
base_present="$2"
status=0
# Bring tool-specific functions into scope
setup_tool "$1" || return 1
@ -221,8 +213,6 @@ run_merge_tool () {
else
run_diff_cmd "$1"
fi
status=$?
return $status
}
# Run a either a configured or built-in diff tool

View File

@ -426,8 +426,6 @@ fi
merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
last_status=0
rollup_status=0
files=
if test $# -eq 0
@ -455,19 +453,15 @@ printf "%s\n" "$files"
IFS='
'
rc=0
for i in $files
do
if test $last_status -ne 0
then
prompt_after_failed_merge || exit 1
fi
printf "\n"
merge_file "$i"
last_status=$?
if test $last_status -ne 0
if ! merge_file "$i"
then
rollup_status=1
rc=1
prompt_after_failed_merge || exit 1
fi
done
exit $rollup_status
exit $rc

View File

@ -11,5 +11,4 @@ merge_cmd () {
"$merge_tool_path" --merge \
--result="$MERGED" "$LOCAL" "$REMOTE"
fi
status=$?
}

View File

@ -15,7 +15,6 @@ merge_cmd () {
"$LOCAL" "$REMOTE" \
"$(basename "$MERGED")"
fi
status=$?
}
translate_merge_tool_path() {

View File

@ -20,5 +20,4 @@ merge_cmd () {
-o "$MERGED" "$LOCAL" "$REMOTE" \
>/dev/null 2>&1
fi
status=$?
}