Skip to content

Do not call cmd_*() as a subroutine

Junio C Hamano git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2describe: do not use cmd_*() as a subroutinebuiltin/describe.c+11 -42 replies
2/2merge-ours: do not use cmd_*() as a subroutinebuiltin/merge-ours.c+7 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Do not call cmd_*() as a subroutine

These two patches are for a recent #leftoverbits topic.

https://public-inbox.org/git/[email protected]/

The cmd_foo() function is a moral equivalent of 'main' for a Git subcommand 'git foo', and as such, it is allowed to do many things that make it unsuitable to be called as a subroutine, including

- call exit(3) to terminate the process;

- allocate resource held and used throughout its lifetime, without releasing it upon return/exit;

- rely on global variables being initialized at program startup, and update them as needed, making another clean invocation of the function impossible.

Correcting two callers by using helper API calls is not so hard.

Junio C Hamano (2):
describe: do not use cmd_*() as a subroutine
merge-ours: do not use cmd_*() as a subroutine

 builtin/describe.c   | 15 +++++++++++----
 builtin/merge-ours.c | 16 +++++++---------
 2 files changed, 18 insertions(+), 13 deletions(-)
Signature · 1 line
2.15.0-rc0-203-g4c8d0e28b1