Skip to content

Fix build error with libgit2 -Wmissing-field-initializers#91

Open
jsyrjala wants to merge 1 commit intoDeusData:mainfrom
jsyrjala:fix/libgit2-diff-options-init
Open

Fix build error with libgit2 -Wmissing-field-initializers#91
jsyrjala wants to merge 1 commit intoDeusData:mainfrom
jsyrjala:fix/libgit2-diff-options-init

Conversation

@jsyrjala
Copy link

@jsyrjala jsyrjala commented Mar 21, 2026

Summary

  • Build fails at pass_githistory.c:171 with -Werror,-Wmissing-field-initializers because GIT_DIFF_OPTIONS_INIT macro doesn't list all struct fields
  • Observed with libgit2 1.9.2 on macOS (Apple clang), but the macro has never listed all fields — any libgit2 version can trigger this depending on compiler warning settings
  • Replace the macro with git_diff_options_init() runtime API, which properly initializes all fields
  • git_diff_options_init() available since libgit2 0.28 (2019)

Test plan

  • Verify scripts/build.sh completes without errors

Fixes #104

🤖 Generated with Claude Code

Build fails at pass_githistory.c:171 with:

  error: missing field 'interhunk_lines' initializer
         [-Werror,-Wmissing-field-initializers]
    git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT;

codebase-memory-mcp at 75b5dcb has this issue. The GIT_DIFF_OPTIONS_INIT
macro does not list all struct fields, which clang flags as an error
under -Werror.

Replace the macro with the runtime git_diff_options_init() API, which
properly initializes all fields. Available since libgit2 0.28.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails with libgit2 1.9.2: -Wmissing-field-initializers error in pass_githistory.c

2 participants