title | layout | date | author | categories | navbar | |
---|---|---|---|---|---|---|
Git Rev News Edition 77 (July 31st, 2021) |
default |
2021-07-31 12:06:51 +0100 |
chriscool |
|
false |
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.
-
[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 areturn
statement instead ofexit()
. 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 byrun_builtin()
ingit.c
to perform the command. For example whengit log
is launched, thecmd_log()
function is called byrun_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 otherexit()
calls.NORETURN
is a special statement to tell the compiler that a function doesn't return, but instead uses a function likeexit()
to stop the current process.Phillip Wood also wondered if SunCC would complain about
die()
calls, which useexit()
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 acmd_*()
function to return anint
. 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 cleanupsgit.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 theatexit()
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 "theatexit()
handlers cannot modify the exit code (both per the C standard, and POSIX)". He also discussed a bit how glibc allowsatexit()
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.
- Git for Windows 2.32.0(2)
- libgit2 1.1.1
- Gerrit Code Review 3.3.5, 3.2.11
- GitHub Enterprise 3.1.3, 3.0.11, 2.22.17
- GitLab 14.1.0, 14.0.6, 14.0.5, 14.0.4, 13.12.8, and 13.11.7, 14.0.3, 13.12.7, 14.0.2, 13.12.6, and 13.11.6
- Bitbucket Server 7.15
- GitKraken 7.7.0
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
- How to Get Better with Git by Ana Vela provides a list of free and paid resources to help you boost your Git know-how.
- Git quick tips #1: git commit --fixup and Git quick tips #2: Working with many branches by Michael Kohl.
- Git For Data Engineers by Kovid Rathee: a shortish guide to source control for data engineers, data analysts, and data scientists.
- How to Learn Git Slowly by Samuel Faure.
- How NOT to use Git in Practice. Ten Git usages, you should know to avoid. by Tapas Adhikary on GreenRoots Blog.
- Elevate your Git-fu! by Abhay Krishna Arunachalam on DEV.to.
- How to Collaborate on Components across Projects with Bit by Eden Ella on DEV.to. The Bit project was mentioned in Git Rev News Edition #45.
- On the Evilness of Feature Branching - A Tale of Two Teams,
one novice practising trunk-based development,
the other very experienced using GitFlow,
by Thierry de Pauw.
- See also Patterns for Managing Source Code Branches by Martin Fowler, mentioned in Git Rev News Edition #63.
- Things I wish Git had: Commit groups by Daniel Janus - to have advantages of topic branch workflow when using "rebase and merge" workflow.
- Git Squash Simplified by Pawel Borkar on DEV.to.
- How Git Branches Work: Git Branches Tutorial, by Beau Carnes, on freeCodeCamp.
- git update: the odyssey for a sensible git pull by Felipe Contreras.
- Optimizing Git’s Merge Machinery, Part IV by Elijah Newren on Palantir Blog.
Git tools and sites
-
diffsitter creates semantically meaningful diffs that ignore formatting differences like spacing. It does so by computing a diff on the AST (abstract syntax tree) of a file rather than computing the diff on the text contents of the file.
diffsitter
uses the parsers from the tree-sitter project to parse source code. Written in Rust, it is very much a work in progress. -
The best 6 VS Code extensions to supercharge Git by Jamie Swift on DEV.to.
-
GitLive is a Visual Studio Code extension to see which branch your teammates are on in VS Code.
-
Git Immersion provides a guided tour that walks through the fundamentals of Git, inspired by the premise that to know a thing is to do it. Another variant of Git Immersion was mentioned in Git Rev News Edition #38.
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.