diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-10-26 19:48:20 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-10-26 19:48:20 -0700 |
| commit | 4b67e53fd671c2e4f3bf49bfff8ca87cdf3c9e22 (patch) | |
| tree | d0cbe59be64ece7d0a91fbc6bfa2d96f3cbd71be | |
| parent | ed931ebe1803bace248f02cb8b26f855baef4b5c (diff) | |
| parent | 3860985105a40f425effc49642693e90e84e1863 (diff) | |
Merge branch 'js/unreachable-workaround-for-no-symlink-head' into maint-2.51
Code clean-up.
* js/unreachable-workaround-for-no-symlink-head:
refs: forbid clang to complain about unreachable code
| -rw-r--r-- | refs/files-backend.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c index 2c89e87d3e..b2de84fa69 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3291,7 +3291,13 @@ static int files_transaction_finish(struct ref_store *ref_store, * next update. If not, we try and create a regular symref. */ if (update->new_target && refs->prefer_symlink_refs) - if (!create_ref_symlink(lock, update->new_target)) + /* + * By using the `NOT_CONSTANT()` trick, we can avoid + * errors by `clang`'s `-Wunreachable` logic that would + * report that the `continue` statement is not reachable + * when `NO_SYMLINK_HEAD` is `#define`d. + */ + if (NOT_CONSTANT(!create_ref_symlink(lock, update->new_target))) continue; if (update->flags & REF_NEEDS_COMMIT) { |
