]> git.ipfire.org Git - thirdparty/git.git/commit
branch: stop modifying `log_all_ref_updates` variable
authorPatrick Steinhardt <ps@pks.im>
Thu, 12 Sep 2024 11:30:10 +0000 (13:30 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 12 Sep 2024 17:15:43 +0000 (10:15 -0700)
commit118fd1a26da681d33dfc65e9dbf74e2dda0c5b3e
tree0e93c970d09b5d3088f46a34a871fb0199bbf429
parentf1d3d07900e42d19f10be55bc2f793034e7d4198
branch: stop modifying `log_all_ref_updates` variable

In "branch.c" we modify the global `log_all_ref_updates` variable to
force creation of a reflog entry. Modifying global state like this is
discouraged, as it may have all kinds of consequences in other places of
our codebase.

Stop modifying the variable and pass the `REF_FORCE_CREATE_REFLOG` flag
instead. Setting this flag has a stronger meaning than setting the
config to `LOG_REFS_NORMAL`:

  - `LOG_REFS_NORMAL` will ask us to only create reflog entries for
    preexisting reflogs or branches, remote refs, note refs and HEAD.

  - `REF_FORCE_CREATE_REFLOG` will unconditionally create a reflog and
    is thus equivalent to `LOG_REFS_ALWAYS`.

But as we are in `create_branch()` and thus do not have to worry about
arbitrary references, but only about branches, `LOG_REFS_NORMAL` and
`LOG_REFS_ALWAYS` are indeed equivalent.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c