Skip to content

Commit 517127e

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 c0bc50d + 007a550 commit 517127e

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
@@ -3302,7 +3302,13 @@ static int files_transaction_finish(struct ref_store *ref_store,
33023302
* next update. If not, we try and create a regular symref.
33033303
*/
33043304
if (update->new_target && refs->prefer_symlink_refs)
3305-
if (!create_ref_symlink(lock, update->new_target))
3305+
/*
3306+
* By using the `NOT_CONSTANT()` trick, we can avoid
3307+
* errors by `clang`'s `-Wunreachable` logic that would
3308+
* report that the `continue` statement is not reachable
3309+
* when `NO_SYMLINK_HEAD` is `#define`d.
3310+
*/
3311+
if (NOT_CONSTANT(!create_ref_symlink(lock, update->new_target)))
33063312
continue;
33073313

33083314
if (update->flags & REF_NEEDS_COMMIT) {

0 commit comments

Comments
 (0)