Skip to content

Commit d6fa764

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 5046853 + ebc0c8e commit d6fa764

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
@@ -3327,7 +3327,13 @@ static int files_transaction_finish(struct ref_store *ref_store,
33273327
* next update. If not, we try and create a regular symref.
33283328
*/
33293329
if (update->new_target && refs->prefer_symlink_refs)
3330-
if (!create_ref_symlink(lock, update->new_target))
3330+
/*
3331+
* By using the `NOT_CONSTANT()` trick, we can avoid
3332+
* errors by `clang`'s `-Wunreachable` logic that would
3333+
* report that the `continue` statement is not reachable
3334+
* when `NO_SYMLINK_HEAD` is `#define`d.
3335+
*/
3336+
if (NOT_CONSTANT(!create_ref_symlink(lock, update->new_target)))
33313337
continue;
33323338

33333339
if (update->flags & REF_NEEDS_COMMIT) {

0 commit comments

Comments
 (0)