@matheusbsbs / matheus-bagliano / commits / 84102a338d
Fork 0

Teach git log --exit-code to return an appropriate exit code

Signed-off-by: Peter Valdemar Mørch <peter@morch.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Peter Valdemar Mørch committed Aug 11, 2008 at 08:46 UTC 84102a338df08a365ed0336304322adc05bc1581
2 files changed +5 -5
builtin-log.c
+4 -4
@@ -218,9 +218,9 @@ static int cmd_log_walk(struct rev_info *rev)
218 finish_early_output(rev);
219
220 /*
221 - * For --check, the exit code is based on CHECK_FAILED being
222 - * accumulated in rev->diffopt, so be careful to retain that state
223 - * information if replacing rev->diffopt in this loop
221 + * For --check and --exit-code, the exit code is based on CHECK_FAILED
222 + * and HAS_CHANGES being accumulated in rev->diffopt, so be careful to
223 + * retain that state information if replacing rev->diffopt in this loop
224 */
225 while ((commit = get_revision(rev)) != NULL) {
226 log_tree_commit(rev, commit);
@@ -236,7 +236,7 @@ static int cmd_log_walk(struct rev_info *rev)
236 DIFF_OPT_TST(&rev->diffopt, CHECK_FAILED)) {
237 return 02;
238 }
239 - return 0;
239 + return diff_result_code(&rev->diffopt, 0);
240 }
241
242 static int git_log_config(const char *var, const char *value, void *cb)
log-tree.c
+1 -1
@@ -432,7 +432,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
432 struct commit_list *parents;
433 unsigned const char *sha1 = commit->object.sha1;
434
435 - if (!opt->diff)
435 + if (!opt->diff && !DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS))
436 return 0;
437
438 /* Root commit? */