git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] mergetool: simplify conditionals

From
David Aguilar <davvid@gmail.com>
Date
Nov 21, 2014, 01:20 UTC
Message-ID
<1416532829-68662-4-git-send-email-davvid@gmail.com>
In-Reply-To
<1416532829-68662-1-git-send-email-davvid@gmail.com>

Combine the $last_status checks into a single conditional. Replace $last_status and $rollup_status with a single variable.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 git-mergetool.sh | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index ff050e5..d20581c 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
-- 
2.2.0.rc2.26.g3e3388f
Previous: David AguilarNext: David Aguilar
Message 5 of 8 in “mergetool/difftool cleanup”
  1. 0/3 mergetool/difftool cleanupDavid Aguilar, Nov 21, 2014
  2. 1/3 mergetool--lib: remove use of $status globalDavid Aguilar, Nov 21, 2014
  3. Junio C HamanoNov 21, 2014
  4. 2/3 difftool--helper: add explicit exit statementDavid Aguilar, Nov 21, 2014
  5. 3/3 mergetool: simplify conditionalsDavid Aguilar, Nov 21, 2014
  6. mergetools: stop setting $status in merge_cmd()David Aguilar, Nov 21, 2014
  7. Junio C HamanoNov 21, 2014
  8. David AguilarNov 22, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.