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>

David Aguilar committed Nov 20, 2014 at 17:20 UTC 1b6a53431c0ffba4fb2428ef09018a5e889f52f8
1 file changed +5 -14
git-mergetool--lib.sh
+5 -14
@@ -92,7 +92,7 @@ translate_merge_tool_path () {
92 check_unchanged () {
93 if test "$MERGED" -nt "$BACKUP"
94 then
95 - status=0
95 + return 0
96 else
97 while true
98 do
@@ -100,8 +100,8 @@ check_unchanged () {
100 printf "Was the merge successful? [y/n] "
101 read answer || return 1
102 case "$answer" in
103 - y*|Y*) status=0; break ;;
104 - n*|N*) status=1; break ;;
103 + y*|Y*) return 0 ;;
104 + n*|N*) return 1 ;;
105 esac
106 done
107 fi
@@ -119,8 +119,6 @@ setup_user_tool () {
119
120 diff_cmd () {
121 ( eval $merge_tool_cmd )
122 - status=$?
123 - return $status
122 }
123
124 merge_cmd () {
@@ -133,9 +131,7 @@ setup_user_tool () {
131 check_unchanged
132 else
133 ( eval $merge_tool_cmd )
136 - status=$?
134 fi
138 - return $status
135 }
136 }
137
@@ -152,13 +148,11 @@ setup_tool () {
148 }
149
150 diff_cmd () {
155 - status=1
156 - return $status
151 + return 1
152 }
153
154 merge_cmd () {
160 - status=1
161 - return $status
155 + return 1
156 }
157
158 translate_merge_tool_path () {
@@ -209,7 +203,6 @@ run_merge_tool () {
203
204 merge_tool_path=$(get_merge_tool_path "$1") || exit
205 base_present="$2"
212 - status=0
206
207 # Bring tool-specific functions into scope
208 setup_tool "$1" || return 1
@@ -220,8 +213,6 @@ run_merge_tool () {
213 else
214 run_diff_cmd "$1"
215 fi
223 - status=$?
224 - return $status
216 }
217
218 # Run a either a configured or built-in diff tool