Skip to content

Latest commit

 

History

History
191 lines (159 loc) · 10.2 KB

2021-07-31-edition-77.markdown

File metadata and controls

191 lines (159 loc) · 10.2 KB
title layout date author categories navbar
Git Rev News Edition 77 (July 31st, 2021)
default
2021-07-31 12:06:51 +0100
chriscool
news
false

Git Rev News: Edition 77 (July 31st, 2021)

Welcome to the 77th edition of Git Rev News, a digest of all things Git. For our goals, the archives, the way we work, and how to contribute or to subscribe, see the Git Rev News page on git.github.io.

This edition covers what happened during the month of June 2021.

Discussions

Reviews

  • [PATCH] builtins + test helpers: use return instead of exit() in cmd_*

    Ævar Arnfjörð Bjarmason sent a patch to the mailing list that changed some cmd_*() functions so that they use a return statement instead of exit(). He further said that it is legitimate for the SunCC compiler on Solaris to complain about the exit() calls, as they would skip any cleanup made after them.

    The cmd_*() functions are important in the architecture of Git, as there is one such function for each Git "builtin" command, and the function is called by run_builtin() in git.c to perform the command. For example when git log is launched, the cmd_log() function is called by run_builtin().

    Felipe Contreras reviewed the patch and found it obviously correct.

    Peff, alias Jeff King, also said that it looked like simple and obvious conversions, but he wondered what was SunCC complaining about, especially if it didn't know about NORETURN, and would complain about many other exit() calls.

    NORETURN is a special statement to tell the compiler that a function doesn't return, but instead uses a function like exit() to stop the current process.

    Phillip Wood also wondered if SunCC would complain about die() calls, which use exit() underneath.

    Ævar then sent a version 2 of his patch, with no code change but explaining that SunCC actually complains when there's no NORETURN while we declare a cmd_*() function to return an int. He replied to Peff with the same explanation and added that around half of SunCC warnings are legitimate, and that he had already been sending miscellaneous fixes for 15-20 of them.

    Junio Hamano, the Git maintainer, replied to the version 2 patch. He especially had an issue with the part in the commit message that said that directly exit()-ing would skip the cleanups git.c would otherwise do, like closing file descriptors and issuing errors if it failed. He considered that it was "not a crime" for the functions to exit themselves as file descriptors are closed when we exit and "if we do have clean-ups that are truly important, we would have arranged them to happen in the atexit() handler".

    Junio anyway thought that the patch was still "a good idea because it encourages good code hygiene".

    Ævar replied to Junio that file descriptors are indeed closed when we exit, but the errors we could get when closing them would not be reported. He pointed to previous commits that had been merged back in 2007 to make sure IO errors were properly reported after the cmd_*() functions return, and said that "the atexit() handlers cannot modify the exit code (both per the C standard, and POSIX)". He also discussed a bit how glibc allows atexit() handlers to munge the exit code though it's not portable behavior.

    Junio replied that Ævar was right and that "we leave a final clean-up for normal returns (i.e. when cmd_foo() intends to return or exit with 0) to be done by the caller".

    The patch was later merged into the master branch and the next version of Git will better signal IO errors, thanks to SunCC and people running it to compile Git on Solaris machines.

Releases

Other News

Various

  • Tower 7 - The New Commit Experience
  • NO_COLOR is a proposed universal standard of disabling colored text output in command-line software programs. The website also documents which software has adopted this standard and when support was added, and for projects that did not adopt this standard it tries to document how to otherwise disable color.

Light reading

Git tools and sites

Credits

This edition of Git Rev News was curated by Christian Couder <[email protected]>, Jakub Narębski <[email protected]>, Markus Jansen <[email protected]> and Kaartic Sivaraam <[email protected]> with help from Elijah Newren.