Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Aguilar authored and Junio C Hamano committed Nov 21, 2014
1 parent e00e13e commit 1b6a534
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions git-mergetool--lib.sh
Expand Up @@ -92,16 +92,16 @@ translate_merge_tool_path () {
check_unchanged () {
if test "$MERGED" -nt "$BACKUP"
then
status=0
return 0
else
while true
do
echo "$MERGED seems 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
Expand All @@ -119,8 +119,6 @@ setup_user_tool () {

diff_cmd () {
( eval $merge_tool_cmd )
status=$?
return $status
}

merge_cmd () {
Expand All @@ -133,9 +131,7 @@ setup_user_tool () {
check_unchanged
else
( eval $merge_tool_cmd )
status=$?
fi
return $status
}
}

Expand All @@ -152,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 () {
Expand Down Expand Up @@ -209,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
Expand All @@ -220,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
Expand Down

0 comments on commit 1b6a534

Please sign in to comment.