mergetool--lib: remove use of $status global

Remove return statements and rework check_unchanged() so that the exit
status from the last evaluated expression bubbles up to the callers.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
David Aguilar 2014-11-20 17:20:27 -08:00 committed by Junio C Hamano
parent e00e13e2aa
commit 1b6a53431c

View File

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