Skip to content

config: clarify iterator entry ownership - #7483

Open
moelomda wants to merge 1 commit into
libgit2:mainfrom
moelomda:docs/config-iterator-ownership-7307
Open

moelomda wants to merge 1 commit into
libgit2:mainfrom
moelomda:docs/config-iterator-ownership-7307

Conversation

@moelomda

Copy link
Copy Markdown

git_config_next documents the lifetime of its result, but does not explicitly say that callers must not free it. Both it and git_config_get_entry return a git_config_entry *, although only the latter transfers ownership to the caller. This ambiguity is reported in #7307.

Clarify that iterator entries are borrowed and must not be passed to git_config_entry_free, and make the same distinction in that function's documentation. The existing iterator lifetime guarantee is preserved.

Validation: checked the iterator and entry-freeing paths in config.c and config_list.c, plus the file, memory, and snapshot backends. C89 and C++11 preprocessing produces identical header output before and after the edit; git diff --check passes. Runtime tests were not run because this changes API comments only.

This documents current ownership; it does not propose a change to the API's ownership model. Investigation and verification used Codex assistance.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 14:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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