Fixing cgit/Git compilation error with GCC 15

Today I was trying to compile and install cgit on my home server. cgit is a "hyperfast web frontend for git repositories written in C".

When attempting to compile a got the following error:

reflog.c:213:104: error: macro 'unreachable' passed 3 arguments, but takes just 0
  213 | static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit, struct object_id *oid)
      |                                                                                                        ^
In file included from git-compat-util.h:237,
                 from reflog.c:3:
/usr/lib/gcc/x86_64-redhat-linux/15/include/stddef.h:468:9: note: macro 'unreachable' defined here
  468 | #define unreachable() (__builtin_unreachable ())
      |         ^~~~~~~~~~~
reflog.c:214:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
  214 | {
      | ^
reflog.c: In function 'should_expire_reflog_ent':
reflog.c:268:61: error: macro 'unreachable' passed 3 arguments, but takes just 0
  268 |                         if (unreachable(cb, old_commit, ooid) || unreachable(cb, new_commit, noid))
      |                                                             ^
/usr/lib/gcc/x86_64-redhat-linux/15/include/stddef.h:468:9: note: macro 'unreachable' defined here
  468 | #define unreachable() (__builtin_unreachable ())
      |         ^~~~~~~~~~~
reflog.c:268:29: error: 'unreachable' undeclared (first use in this function); did you mean 'mark_reachable'?
  268 |                         if (unreachable(cb, old_commit, ooid) || unreachable(cb, new_commit, noid))
      |                             ^~~~~~~~~~~
      |                             mark_reachable
reflog.c:268:29: note: each undeclared identifier is reported only once for each function it appears in
reflog.c:268:98: error: macro 'unreachable' passed 3 arguments, but takes just 0
  268 |                         if (unreachable(cb, old_commit, ooid) || unreachable(cb, new_commit, noid))
      |                                                                                                  ^
/usr/lib/gcc/x86_64-redhat-linux/15/include/stddef.h:468:9: note: macro 'unreachable' defined here
  468 | #define unreachable() (__builtin_unreachable ())
      |         ^~~~~~~~~~~

It appears that GCC 15 introduced a new unreachable() macro in stddef.h that conflicts with Git's function named unreachable() in reflog.c.

The fix for me was to add #undef unreachable to git/reflog.c which undefines the GCC macro, allowing Git's function to compile normally.

This issue comes from the fact that cgit uses an older version of Git, more specifically "2.46.0". Trying to use the latest version breaks the compilation in other ways due to renamed/removed header files in Git, on which cgit depends.