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

[PATCH v1] merge - rename a shadowed variable in cmd_merge

From
Edmundo Carmona Antoranz <eantoranz@gmail.com>
Date
Jul 5, 2019, 20:32 UTC
Message-ID
<20190705203227.23451-1-eantoranz@gmail.com>

variable ret used in cmd_merge introduced in d5a35c114ab was already a local variable used inside a for loop inside the function.

for-local variable is being renamed to ret_try_merge to avoid shadow.
---
 builtin/merge.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index 6e99aead46..972b6c376a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1587,7 +1587,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		oidclr(&stash);
 
 	for (i = 0; i < use_strategies_nr; i++) {
-		int ret;
+		int ret_try_merge;
 		if (i) {
 			printf(_("Rewinding the tree to pristine...\n"));
 			restore_state(&head_commit->object.oid, &stash);
@@ -1601,26 +1601,26 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		 */
 		wt_strategy = use_strategies[i]->name;
 
-		ret = try_merge_strategy(use_strategies[i]->name,
-					 common, remoteheads,
-					 head_commit);
-		if (!option_commit && !ret) {
+		ret_try_merge = try_merge_strategy(use_strategies[i]->name,
+						common, remoteheads,
+						head_commit);
+		if (!option_commit && !ret_try_merge) {
 			merge_was_ok = 1;
 			/*
 			 * This is necessary here just to avoid writing
 			 * the tree, but later we will *not* exit with
 			 * status code 1 because merge_was_ok is set.
 			 */
-			ret = 1;
+			ret_try_merge = 1;
 		}
 
-		if (ret) {
+		if (ret_try_merge) {
 			/*
 			 * The backend exits with 1 when conflicts are
 			 * left to be resolved, with 2 when it does not
 			 * handle the given merge at all.
 			 */
-			if (ret == 1) {
+			if (ret_try_merge == 1) {
 				int cnt = evaluate_result();
 
 				if (best_cnt <= 0 || cnt <= best_cnt) {
-- 
2.22.0.214.g8dca754b1e
Next: Junio C Hamano
Message 1 of 2 in “merge - rename a shadowed variable in cmd_merge”
  1. merge - rename a shadowed variable in cmd_mergeEdmundo Carmona Antoranz, Jul 5, 2019
  2. Junio C HamanoJul 8, 2019

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.