Skip to content

export all internal git functions - #7296

Draft
milahu wants to merge 114 commits into
libgit2:mainfrom
milahu:export-all-git-functions
Draft

export all internal git functions#7296
milahu wants to merge 114 commits into
libgit2:mainfrom
milahu:export-all-git-functions

Conversation

@milahu

@milahu milahu commented Jun 14, 2026

Copy link
Copy Markdown

probably this will never get merged → draft PR

i needed some internal functions

git_iterator_for_tree
git_iterator_current
git_iterator_advance
git_iterator_free

to build a custom version of git_diff_tree_to_tree
for my git-file-times
where i dont need full tree diffs
but i only need to know "was this file added or modified or renamed"

so i exported all the internal git_* functions

in 8882239 i fixed a typecast for C++

seems to work... at least on linux
build is passing, tests are passing, downstream build is passing

edit: fixme:

In file included from /home/libgit2/source/tests/libgit2/apply/apply_helpers.c:1:
/home/libgit2/source/tests/libgit2/apply/apply_helpers.c: In function 'validate_index_unchanged':
/home/libgit2/source/tests/libgit2/apply/apply_helpers.c:92:21: error: implicit declaration of function 'git_repository_head_tree'; did you mean 'git_repository_oid_type'? [-Werror=implicit-function-declaration]
   92 |         cl_git_pass(git_repository_head_tree(&head, repo));
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~

maybe caused by a broken include

@ethomson

Copy link
Copy Markdown
Member

Instead of trying to make everything internal be external, can we create a simpler API that can provide the information that you're looking for directly?

@milahu

milahu commented Jun 26, 2026

Copy link
Copy Markdown
Author

i have abandoned this path
in favor of a compare_tree_nway function
which does a merge walk of multiple git trees
(the parent trees of merge commits)
to emit "add blob" and "delete blob" events
based on

git_tree_lookup
git_tree_entrycount
git_tree_entry_byindex
git_tree_entry_name
git_tree_entry_type
git_tree_entry_id

so this problem is solvable without the git_iterator_* functions

my current solution is already 20 times faster than git_diff_tree_to_tree
(1000 commits/second versus 50 commits/second)

having the git_iterator_* functions in the public API
would only be interesting if they offer better performance
than the git_tree_entry_* functions

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.

2 participants