summaryrefslogtreecommitdiff
path: root/refs/files-backend.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-10-20 14:12:17 -0700
committerJunio C Hamano <gitster@pobox.com>2025-10-20 14:12:17 -0700
commit5a34f66fb9024571c3099d91d4b0d8f88a55a8ea (patch)
treecf5cc4773385bbb16251f50158f5d781748b31c5 /refs/files-backend.c
parentfc00bf0f9c609ff4ad3a8a4cf60bf53af3f93fc7 (diff)
parent3860985105a40f425effc49642693e90e84e1863 (diff)
Merge branch 'js/unreachable-workaround-for-no-symlink-head'
Code clean-up. * js/unreachable-workaround-for-no-symlink-head: refs: forbid clang to complain about unreachable code
Diffstat (limited to 'refs/files-backend.c')
-rw-r--r--refs/files-backend.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 5ddf418b18..8d7007f4aa 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -3327,7 +3327,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) {