diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-12-12 14:31:39 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-12-12 14:31:39 -0800 |
commit | 0ddedd4d6b9b3e8eb3557d8ed28e1a0b354a25f8 (patch) | |
tree | bec8ec6f7d910bce51a681bb81a601709d95c54a | |
parent | e886efdb342cee6722762e654ddc1fdee37315b5 (diff) | |
parent | 1e86d5b11dcf31adf11363caa1e96a94612b16f4 (diff) | |
download | git-0ddedd4d6b9b3e8eb3557d8ed28e1a0b354a25f8.tar.gz git-0ddedd4d6b9b3e8eb3557d8ed28e1a0b354a25f8.tar.xz |
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
-rwxr-xr-x | git-difftool--helper.sh | 2 | ||||
-rw-r--r-- | git-mergetool--lib.sh | 20 | ||||
-rwxr-xr-x | git-mergetool.sh | 16 | ||||
-rw-r--r-- | mergetools/diffmerge | 1 | ||||
-rw-r--r-- | mergetools/emerge | 1 | ||||
-rw-r--r-- | mergetools/kdiff3 | 1 |
6 files changed, 12 insertions, 29 deletions
diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index d4fb6dfe1..2b11b1d6f 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -94,3 +94,5 @@ else shift 7 done fi + +exit 0 diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index 2b6635130..fe61e89f3 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -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 diff --git a/git-mergetool.sh b/git-mergetool.sh index ff050e58f..d20581c15 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -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 diff --git a/mergetools/diffmerge b/mergetools/diffmerge index 85ac72015..f138cb4e7 100644 --- a/mergetools/diffmerge +++ b/mergetools/diffmerge @@ -11,5 +11,4 @@ merge_cmd () { "$merge_tool_path" --merge \ --result="$MERGED" "$LOCAL" "$REMOTE" fi - status=$? } diff --git a/mergetools/emerge b/mergetools/emerge index f96d9e550..7b895fdb1 100644 --- a/mergetools/emerge +++ b/mergetools/emerge @@ -15,7 +15,6 @@ merge_cmd () { "$LOCAL" "$REMOTE" \ "$(basename "$MERGED")" fi - status=$? } translate_merge_tool_path() { diff --git a/mergetools/kdiff3 b/mergetools/kdiff3 index a30034f11..793d1293b 100644 --- a/mergetools/kdiff3 +++ b/mergetools/kdiff3 @@ -20,5 +20,4 @@ merge_cmd () { -o "$MERGED" "$LOCAL" "$REMOTE" \ >/dev/null 2>&1 fi - status=$? } |