Skip to content

Commit e867110

Browse files
committed
Merge branch 'ab/cmd-foo-should-return'
Code clean-up. * ab/cmd-foo-should-return: builtins + test helpers: use return instead of exit() in cmd_*
2 parents 11819cb + 338abb0 commit e867110

File tree

9 files changed

+13
-14
lines changed

9 files changed

+13
-14
lines changed

builtin/difftool.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ static int run_file_diff(int prompt, const char *prefix,
675675
"GIT_PAGER=", "GIT_EXTERNAL_DIFF=git-difftool--helper", NULL,
676676
NULL
677677
};
678-
int ret = 0, i;
678+
int i;
679679

680680
if (prompt > 0)
681681
env[2] = "GIT_DIFFTOOL_PROMPT=true";
@@ -686,8 +686,7 @@ static int run_file_diff(int prompt, const char *prefix,
686686
strvec_push(&args, "diff");
687687
for (i = 0; i < argc; i++)
688688
strvec_push(&args, argv[i]);
689-
ret = run_command_v_opt_cd_env(args.v, RUN_GIT_CMD, prefix, env);
690-
exit(ret);
689+
return run_command_v_opt_cd_env(args.v, RUN_GIT_CMD, prefix, env);
691690
}
692691

693692
int cmd_difftool(int argc, const char **argv, const char *prefix)

builtin/merge-ours.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ int cmd_merge_ours(int argc, const char **argv, const char *prefix)
2828
if (read_cache() < 0)
2929
die_errno("read_cache failed");
3030
if (index_differs_from(the_repository, "HEAD", NULL, 0))
31-
exit(2);
32-
exit(0);
31+
return 2;
32+
return 0;
3333
}

builtin/mktree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,5 @@ int cmd_mktree(int ac, const char **av, const char *prefix)
189189
used=0; /* reset tree entry buffer for re-use in batch mode */
190190
}
191191
strbuf_release(&sb);
192-
exit(0);
192+
return 0;
193193
}

sh-i18n--envsubst.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ cmd_main (int argc, const char *argv[])
104104
if (ferror (stderr) || fflush (stderr))
105105
{
106106
fclose (stderr);
107-
exit (EXIT_FAILURE);
107+
return (EXIT_FAILURE);
108108
}
109109
if (fclose (stderr) && errno != EBADF)
110-
exit (EXIT_FAILURE);
110+
return (EXIT_FAILURE);
111111

112-
exit (EXIT_SUCCESS);
112+
return (EXIT_SUCCESS);
113113
}
114114

115115
/* Parse the string and invoke the callback each time a $VARIABLE or

shell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ int cmd_main(int argc, const char **argv)
177177
default:
178178
continue;
179179
}
180-
exit(cmd->exec(cmd->name, arg));
180+
return cmd->exec(cmd->name, arg);
181181
}
182182

183183
cd_to_homedir();

t/helper/test-hash-speed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ int cmd__hash_speed(int ac, const char **av)
5757
free(p);
5858
}
5959

60-
exit(0);
60+
return 0;
6161
}

t/helper/test-hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ int cmd_hash_impl(int ac, const char **av, int algo)
5454
fwrite(hash, 1, algop->rawsz, stdout);
5555
else
5656
puts(hash_to_hex_algop(hash, algop));
57-
exit(0);
57+
return 0;
5858
}

t/helper/test-match-trees.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ int cmd__match_trees(int ac, const char **av)
2323
shift_tree(the_repository, &one->object.oid, &two->object.oid, &shifted, -1);
2424
printf("shifted: %s\n", oid_to_hex(&shifted));
2525

26-
exit(0);
26+
return 0;
2727
}

t/helper/test-reach.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,5 @@ int cmd__reach(int ac, const char **av)
166166
print_sorted_commit_ids(list);
167167
}
168168

169-
exit(0);
169+
return 0;
170170
}

0 commit comments

Comments
 (0)