Skip to content

Commit e05fcf2

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 1303bdc + 1b67791 commit e05fcf2

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

33343340
if (update->flags & REF_NEEDS_COMMIT) {

0 commit comments

Comments
 (0)