commit 4f8c39725ac4af2acc4f0f28ce8c4630c9a745f1
parent d0ff6f6ced5c7d330536644517596a5814b14918
Author: Chris Bracken <chris@bracken.jp>
Date: Sat, 6 Jun 2026 14:57:09 +0900
git: support SHA-256 OIDs
Increase GOUT_OID_MAX_SIZE to 65 to support 64-character SHA-256 OIDs.
Relax the static assertion in git.c to a greater-than-or-equal check,
which allows backward compatibility with previous 40-byte OIDs.
Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/git/constants.h b/src/git/constants.h
@@ -3,7 +3,7 @@
/* Maximum length of a hex-encoded OID string, including null terminator.
* (Matches GIT_OID_MAX_HEXSIZE + 1) */
-#define GOUT_OID_MAX_SIZE 41
+#define GOUT_OID_MAX_SIZE 65
/* Maximum length of a file mode string, including null terminator.
* (e.g. "m---------") */
diff --git a/src/git/git.c b/src/git/git.c
@@ -12,8 +12,8 @@
#include "third_party/openbsd/reallocarray.h"
/* Global const data. */
-static_assert(GOUT_OID_MAX_SIZE == GIT_OID_MAX_HEXSIZE + 1,
- "GOUT_OID_MAX_SIZE must match libgit2's OID size");
+static_assert(GOUT_OID_MAX_SIZE >= GIT_OID_MAX_HEXSIZE + 1,
+ "GOUT_OID_MAX_SIZE must be large enough to hold libgit2's OID");
/* Maximum file size to load into memory, in bytes. */
static const ssize_t kMaxFileSizeBytes = 16 * 1024 * 1024;