Skip to content

Commit 1b6a534

Browse files
davvidgitster
authored andcommitted
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>
1 parent e00e13e commit 1b6a534

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

git-mergetool--lib.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ translate_merge_tool_path () {
9292
check_unchanged () {
9393
if test "$MERGED" -nt "$BACKUP"
9494
then
95-
status=0
95+
return 0
9696
else
9797
while true
9898
do
9999
echo "$MERGED seems unchanged."
100100
printf "Was the merge successful? [y/n] "
101101
read answer || return 1
102102
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 ;;
105105
esac
106106
done
107107
fi
@@ -119,8 +119,6 @@ setup_user_tool () {
119119

120120
diff_cmd () {
121121
( eval $merge_tool_cmd )
122-
status=$?
123-
return $status
124122
}
125123

126124
merge_cmd () {
@@ -133,9 +131,7 @@ setup_user_tool () {
133131
check_unchanged
134132
else
135133
( eval $merge_tool_cmd )
136-
status=$?
137134
fi
138-
return $status
139135
}
140136
}
141137

@@ -152,13 +148,11 @@ setup_tool () {
152148
}
153149

154150
diff_cmd () {
155-
status=1
156-
return $status
151+
return 1
157152
}
158153

159154
merge_cmd () {
160-
status=1
161-
return $status
155+
return 1
162156
}
163157

164158
translate_merge_tool_path () {
@@ -209,7 +203,6 @@ run_merge_tool () {
209203

210204
merge_tool_path=$(get_merge_tool_path "$1") || exit
211205
base_present="$2"
212-
status=0
213206

214207
# Bring tool-specific functions into scope
215208
setup_tool "$1" || return 1
@@ -220,8 +213,6 @@ run_merge_tool () {
220213
else
221214
run_diff_cmd "$1"
222215
fi
223-
status=$?
224-
return $status
225216
}
226217

227218
# Run a either a configured or built-in diff tool

0 commit comments

Comments
 (0)