Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed
- Building against a libgit2 compiled with `GIT_EXPERIMENTAL_SHA256` is
now rejected at compile time with an actionable `#error` message via
the new `src/git_compat.hpp` (the single include point for git2
headers, probing `GIT_OID_SHA256_HEXSIZE`): the experimental build's
3-argument `git_oid_fromstr` and larger `git_oid` ABI are unsupported
in v0.1, and the previous failure was a bare "too few arguments" at
two call sites with no guidance.
- The system libgit2 minimum is now 1.7 (was 1.4, a declaration that did
not match reality): `git_repository_oid_type` and the `git_oid_t` enum
first appeared in libgit2 v1.7.0, so 1.4–1.6 system libraries failed
to compile. The vendored path pins v1.9.7 and is unaffected.
- RFC 0000 §1.3 (non-goals) now records SHA-256 object-format
repositories as out of scope for v0.1 — they require an experimental
libgit2 build, which the compile-time guard rejects until properly
supported.

## [0.0.4] - 2026-09-26

### Fixed
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ find_package(PkgConfig REQUIRED)
pkg_check_modules(FUSE3 REQUIRED IMPORTED_TARGET fuse3>=3.10)
find_package(Threads REQUIRED)

# System libgit2 (>= 1.4) by default; a pinned vendored copy (v1.9.7,
# System libgit2 (>= 1.7) by default; a pinned vendored copy (v1.9.7,
# static, network backends disabled) is used when the system version is
# too old — e.g. Ubuntu 22.04 ships libgit2 1.1. The vendored path also
# produces release binaries with one less runtime dependency.
option(GITMOUNT_USE_SYSTEM_LIBGIT2 "Link the system libgit2 (pkg-config); OFF builds a pinned vendored copy" ON)

if(GITMOUNT_USE_SYSTEM_LIBGIT2)
pkg_check_modules(LIBGIT2 REQUIRED IMPORTED_TARGET libgit2>=1.4)
# git_repository_oid_type (gitrepo.cpp) and the git_oid_t enum (rawobj)
# first appeared in libgit2 v1.7.0 — older system libraries fail to
# compile. The vendored path pins v1.9.7 and is unaffected.
pkg_check_modules(LIBGIT2 REQUIRED IMPORTED_TARGET libgit2>=1.7)
set(GITMOUNT_LIBGIT2_TARGET PkgConfig::LIBGIT2)
else()
include(FetchContent)
Expand Down
2 changes: 2 additions & 0 deletions rfc/0000-gitmount.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ commit 解析为一个 commit 对象,
- 稀疏检出、部分克隆(partial clone)。
- macOS(osxfuse/macFUSE)与 BSD 移植(接口层预留抽象)。
- 工作区(index)视图、stash 视图。
- SHA-256 对象格式仓库(v0.1;需 libgit2 实验构建,编译期守卫先行
拒绝)。

## 2. 术语与要求用语

Expand Down
2 changes: 1 addition & 1 deletion src/errmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <cerrno>

#include <git2.h>
#include "git_compat.hpp"

namespace gitmount {

Expand Down
17 changes: 17 additions & 0 deletions src/git_compat.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// gitmount — read-only git-to-FUSE filesystem (RFC 0000).
// SPDX-FileCopyrightText: 2026 The gitmount authors
// SPDX-License-Identifier: GPL-3.0-or-later
//
// Unified libgit2 include point (issue #8): every translation unit that
// needs git2 headers includes this file instead of <git2.h> directly, so
// the compile-time guard below is enforced for the whole program — not
// just the TUs that happen to include <git2.h> themselves.
#pragma once

#include <git2.h>

#ifdef GIT_OID_SHA256_HEXSIZE
// 该宏仅在 libgit2 以 GIT_EXPERIMENTAL_SHA256 构建的头文件分支中定义。
#error \
"gitmount v0.1 does not support libgit2 built with GIT_EXPERIMENTAL_SHA256: the git_oid API/ABI differs (3-argument git_oid_fromstr, larger git_oid). See RFC 0000 §1.3."
#endif
2 changes: 1 addition & 1 deletion src/gitrepo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <string>
#include <vector>

#include <git2.h>
#include "git_compat.hpp"

namespace gitmount {

Expand Down
2 changes: 1 addition & 1 deletion src/rawobj.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <string_view>
#include <vector>

#include <git2.h>
#include "git_compat.hpp"

namespace gitmount::rawobj {

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_errmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "errmap.hpp"

#include <git2.h>
#include "git_compat.hpp"

using gitmount::git_to_errno;

Expand Down
Loading