Skip to content

Commit 7acdb99

Browse files
committed
Merge branch 'refs-clang-fix'
Another work-around for clang's `-Wunreachable` mode being ill-prepared for cross-platform code. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 052dd35 + 8fd28cd commit 7acdb99

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

refs/files-backend.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3255,7 +3255,13 @@ static int files_transaction_finish(struct ref_store *ref_store,
32553255
* next update. If not, we try and create a regular symref.
32563256
*/
32573257
if (update->new_target && refs->prefer_symlink_refs)
3258-
if (!create_ref_symlink(lock, update->new_target))
3258+
/*
3259+
* By using the `NOT_CONSTANT()` trick, we can avoid
3260+
* errors by `clang`'s `-Wunreachable` logic that would
3261+
* report that the `continue` statement is not reachable
3262+
* when `NO_SYMLINK_HEAD` is `#define`d.
3263+
*/
3264+
if (NOT_CONSTANT(!create_ref_symlink(lock, update->new_target)))
32593265
continue;
32603266

32613267
if (update->flags & REF_NEEDS_COMMIT) {

0 commit comments

Comments
 (0)