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

Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 23, 2022, 11:13 UTC
Message-ID
<xmqqsfr8udku.fsf@gitster.g>
In-Reply-To
<220322.86r16unzer.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> We also document for some of these programs that on failure we'll
> return 1 specifically, not whatever EXIT_FAILURE is.

I view this as a real issue. EXIT_FAILURE could by happenstance be defined to be the same value on all platforms we care about, but if it leaves the possibility that the next major thing will break our assumption, I do not see much point in adopting it. Whole-sale rewriting of 0 and 1 to EXIT_SUCCESS and EXIT_FAILURE smells like adopting a bad standardization without thinking things through, only for the sake of adopting "standardization".

> ... but we should fix the exit(-1) cases, and that's best done
> with some new GIT_TEST_ASSERT_NO_UNPORTABLE_EXIT testing or
> whatever.

That is probably a good #leftoverbit, even a candidate for future #microprojects.

Show 7 quoted lines
> I think we'd be much better off with something like this in
> git-compat-util.h:
>
>     #ifndef BYPASS_EXIT_SANITY
>     #ifdef EXIT_SUCCESS
>     #if EXIT_SUCCESS != 0
>     #error "git assumes EXIT_SUCCESS is 0, not whatever yours is, please report this. Build with -DBYPASS_EXIT_SANITY to continue building at your own risk"
This is not a good idea.  EXIT_SUCCESS does not have to be literally
0.  It only has to be a value that causes the process to exit with 0
when passed to exit().
>     #endif
>     #endif
>     #ifdef EXIT_FAILURE
>     #if EXIT_FAILURE != 0

I think you meant "!= 1". If we were to take these 41 patches, we must have this hunk, as we want our plumbing tools to be drivable by shell scripts, i.e.

	git foo ||
	case $? in
	1) # generic failure
		...
	esac
and we do not want to be forced to write something like
	. git-stdlib-util.sh ;# for platform-dependent $EXIT_FAILURE
	...
	git foo ||
	case $? in
	$EXIT_FAILURE) # generic failure
		...
	esac
	
instead.
Previous: Elia Pinto
Message 48 of 48 in “use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status”
  1. 00/41 use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  2. 07/41 help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  3. 13/41 rebase.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  4. 34/41 setup.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  5. 05/41 commit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  6. 02/41 branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  7. 40/41 upload-pack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  8. 32/41 remote-curl.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  9. 27/41 git.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  10. 26/41 daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  11. 41/41 exit.cocci: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  12. 01/41 archive.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  13. 24/41 git-credential-osxkeychain.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  14. 20/41 tag.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  15. 09/41 mailsplit.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  16. 38/41 test-submodule-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  17. 11/41 merge.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  18. 17/41 shortlog.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  19. 12/41 pull.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  20. 37/41 test-reach.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  21. 33/41 run-command.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  22. 16/41 rm.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  23. 31/41 path.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  24. 04/41 blame.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  25. 15/41 rev-parse.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  26. 29/41 http-backend.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  27. 18/41 show-branch.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  28. 03/41 am.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  29. 36/41 test-json-writer.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  30. 28/41 help.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  31. 39/41 test-submodule-nested-repo-config.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  32. 06/41 credential-cache--daemon.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  33. 14/41 remote-ext.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  34. 10/41 merge-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  35. 25/41 git-credential-wincred.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  36. 22/41 update-index.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  37. 08/41 init-db.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  38. 23/41 obstack.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  39. 21/41 unpack-objects.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  40. 30/41 parse-options.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  41. 19/41 stash.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  42. 35/41 shell.c: use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit statusElia Pinto, Mar 21, 2022
  43. Bagas SanjayaMar 22, 2022
  44. Elia PintoMar 22, 2022
  45. Bagas SanjayaMar 22, 2022
  46. Ævar Arnfjörð BjarmasonMar 22, 2022
  47. Elia PintoMar 22, 2022
  48. Junio C HamanoMar 23, 2022

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.