Skip to content

chore: drop optional libgit2 dependency (keep git log fallback)#865

Merged
DeusData merged 1 commit into
mainfrom
chore/remove-libgit2
Jul 4, 2026
Merged

chore: drop optional libgit2 dependency (keep git log fallback)#865
DeusData merged 1 commit into
mainfrom
chore/remove-libgit2

Conversation

@DeusData

@DeusData DeusData commented Jul 4, 2026

Copy link
Copy Markdown
Owner

What

Removes the optional libgit2 dependency entirely. The git log popen
fallback — which release binaries already used — becomes the sole
git-history implementation. HAVE_LIBGIT2 no longer exists anywhere in
the tree.

Why

libgit2 is licensed GPLv2-with-linking-exception, and this project is
deliberately GPL-free (see scripts/license-policy.json). libgit2 was
only a faster git-history path, auto-detected via pkg-config and guarded
by HAVE_LIBGIT2, always sitting behind a popen("git log ...") fallback.
Release binaries are built without libgit2, so they already ran the
fallback — meaning there is no change to shipped behavior.

Files touched

  • src/pipeline/pass_githistory.c — collapse the HAVE_LIBGIT2 #ifdef
    so only the popen parse_git_log remains; drop the now-unused
    <git2.h> / <time.h> includes.
  • internal/cbm/cbm.c, internal/cbm/cbm.h, src/main.c,
    src/foundation/subprocess.c, src/mcp/index_supervisor.h — remove the
    libgit2 mimalloc allocator bind + its >=1.7.0 version guards; keep the
    tree-sitter + sqlite3 binds; correct the comments.
  • Makefile.cbm — remove the optional-libgit2 pkg-config detection block,
    the REQUIRE_LIBGIT2 error gate, and all LIBGIT2 CFLAGS/LIBS/FLAGS.
  • .github/workflows/_test.yml — drop the REQUIRE_LIBGIT2 test-matrix
    leg and its libgit2-dev/pkg-config apt install.
  • flake.nix — drop libgit2/pkg-config from the dev shell (dead dep).
  • scripts/security-allowlist.txt — comment now says "git log" instead of
    "fallback when libgit2 not available".

Tradeoff

A local dev build that had libgit2 installed loses the (slightly faster)
libgit2 history path. Release binaries are unaffected — they never linked
libgit2.

CI-sensitivity note

Edits .github/workflows/_test.yml: removes one REQUIRE_LIBGIT2 matrix
leg and its apt install → lower CI cost. No new gating jobs, no
2x/UI-build cost, no trigger-scope change.

Verification

  • grep for libgit2|HAVE_LIBGIT2|LIBGIT2|git_libgit2|git_allocator|git2
    across src/ internal/ Makefile.cbm .github/: empty (only the
    historical tests/windows/RED_TEST_ANALYSIS.md analysis doc still
    mentions it, intentionally left untouched).
  • Production build (make -f Makefile.cbm cbm): clean, no warnings;
    compile lines contain no -DHAVE_LIBGIT2; link line has no libgit2 libs.
  • ASan test build (make -f Makefile.cbm build/c/test-runner): clean.
  • test-runner pipeline: 215 passed — all 9 githistory_* tests green.
  • test-runner integration git_context: 27 passed.
  • End-to-end: indexing a real 3-commit git repo logs
    pass.done pass=githistory commits=3 edges=1 — the popen parse_git_log
    parses real history and produces the FILE_CHANGES_WITH coupling edge.

Merge as a merge commit (not squash).

libgit2 is licensed GPLv2-with-linking-exception, and this project is
deliberately GPL-free (see scripts/license-policy.json). libgit2 was only
an OPTIONAL, faster git-history code path guarded by HAVE_LIBGIT2 and
auto-detected via pkg-config; it always shipped with a popen("git log ...")
fallback that release binaries already used (they were built without
libgit2). Making that popen fallback the SOLE git-history implementation
means there is NO change to shipped behavior.

Changes:
- pass_githistory.c: collapse the HAVE_LIBGIT2 #ifdef so only the popen
  parse_git_log remains; drop the now-unused <git2.h>/<time.h> includes.
- cbm.c / cbm.h / main.c / subprocess.c / index_supervisor.h: remove the
  libgit2 mimalloc allocator bind and its >=1.7.0 version guards; keep the
  tree-sitter + sqlite3 binds; correct the comments.
- Makefile.cbm: remove the optional-libgit2 pkg-config detection block,
  the REQUIRE_LIBGIT2 error gate, and all LIBGIT2 CFLAGS/LIBS/FLAGS.
- .github/workflows/_test.yml: drop the REQUIRE_LIBGIT2 test-matrix leg
  plus its libgit2-dev/pkg-config apt install (lower CI cost, no new
  gating, no trigger change).
- flake.nix: drop libgit2/pkg-config from the dev shell (now-dead dep).

HAVE_LIBGIT2 no longer exists anywhere in the tree.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant