git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* "git diff --no-pager --exit-code" errors out but returns zero exit code
@ 2023-08-20 19:52 Romain Chossart
  2023-08-21  0:35 ` [PATCH] diff: handle negative status in diff_result_code() Jeff King
  0 siblings, 1 reply; 19+ messages in thread
From: Romain Chossart @ 2023-08-20 19:52 UTC (permalink / raw)
  To: git

I recently found out (the hard way :-) ) that running the following
command prints an appropriate error on stderr but returns a zero exit
code:

> $ git diff --no-pager --exit-code
> error: invalid option: --no-pager
> $ echo $?
> 0

I would expect a non-zero exit code to be returned.

Interestingly, running `git diff --no-pager --exit-code HEAD` shows a
usage instead and does return a non-zero exit code as expected.

Thanks,
-- 
Romain Chossart

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-08-23 19:01 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-20 19:52 "git diff --no-pager --exit-code" errors out but returns zero exit code Romain Chossart
2023-08-21  0:35 ` [PATCH] diff: handle negative status in diff_result_code() Jeff King
2023-08-21 15:56   ` Junio C Hamano
2023-08-21 16:21     ` [PATCH] diff: spell DIFF_INDEX_CACHED out when calling run_diff_index() Junio C Hamano
2023-08-21 18:36       ` Jeff King
2023-08-21 22:08         ` Junio C Hamano
2023-08-21 18:09     ` [PATCH] diff: handle negative status in diff_result_code() Jeff King
2023-08-21 18:39       ` Junio C Hamano
2023-08-21 20:13         ` [PATCH v2 0/7] cleaning up diff_result_code() Jeff King
2023-08-21 20:14           ` [PATCH v2 1/7] diff: spell DIFF_INDEX_CACHED out when calling run_diff_index() Jeff King
2023-08-21 20:15           ` [PATCH v2 2/7] diff-files: avoid negative exit value Jeff King
2023-08-21 20:16           ` [PATCH v2 3/7] diff: show usage for unknown builtin_diff_files() options Jeff King
2023-08-21 20:17           ` [PATCH v2 4/7] diff: die when failing to read index in git-diff builtin Jeff King
2023-08-22 23:27             ` Junio C Hamano
2023-08-21 20:18           ` [PATCH v2 5/7] diff: drop useless return from run_diff_{files,index} functions Jeff King
2023-08-21 20:19           ` [PATCH v2 6/7] diff: drop useless return values in git-diff helpers Jeff King
2023-08-21 20:20           ` [PATCH v2 7/7] diff: drop useless "status" parameter from diff_result_code() Jeff King
2023-08-22 23:38             ` Junio C Hamano
2023-08-23 19:00               ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).