Skip to content

Fix two defects left by the libgit2 1.x API migration - #107

Merged
hannesa2 merged 2 commits into
gitx:masterfrom
goneng:fix-merge-input-init-and-credential-accessor
Sep 21, 2026
Merged

hannesa2 merged 2 commits into
gitx:masterfrom
goneng:fix-merge-input-init-and-credential-accessor

Conversation

@goneng

@goneng goneng commented Sep 20, 2026

Copy link
Copy Markdown

Two call sites that the 1.x rename converted incorrectly, both visible as
compiler warnings on master today.

  • Call git_merge_file_input_init for ourInput in
    -contentsOfDiffWithAncestor:ourSide:theirSide:error:. It was calling
    git_merge_file_options_init, whose 48 byte template is memcpy'd over
    the 40 byte git_merge_file_input, overrunning the stack object by 8
    bytes. Both structs open with a version field of 1, so the version
    check passed and nothing reported it. The two sibling call sites on
    either side of it were converted correctly.
  • Rename GTCredential's private git_cred property to git_credential,
    so the accessor GTCredential.h:90 has declared since the rename
    actually exists. Sending -git_credential to a GTCredential raised an
    unrecognized selector.

Test plan:

  • Archive the framework at 442b5dd4 and on this branch. Master warns at
    GTRepository+Merging.m:202 (-Wincompatible-pointer-types) and
    GTCredential.m:46 (-Wincomplete-implementation); on this branch both
    are gone and the archive succeeds.
  • No spec covers either change, because the ObjectiveGitTests target does
    not compile against 1.9.x: NSDataGitSpec.m reads git_buf.asize,
    which 1.x removed, and the "Test project" step in BuildPR.yml is
    commented out.
  • Worth noting GTRepositorySpec.m:263 does exercise the merge path, so
    it would have caught the first defect had it been runnable. Happy to
    follow up with the test target separately.

The libgit2 1.x rename touched three call sites in this function and the
middle one landed on the options initializer instead of the input one.

* Call git_merge_file_input_init for ourInput, matching the ancestor and
  their-side call sites on either side of it.
* Stop overrunning the stack object: the options initializer memcpy's a
  48 byte template over a 40 byte git_merge_file_input. Both structs
  open with a version field of 1, so the version check passed and the
  mismatch went unreported.
The libgit2 type rename reached every use of git_cred in the file except
the property itself, leaving the header promising a method that nothing
implements.

* Rename the private property to git_credential so its synthesized
  getter satisfies the declaration in GTCredential.h, and update the two
  places that read it.
* Restore the public accessor: sending -git_credential to a GTCredential
  raised an unrecognized selector, and the framework built with a
  -Wincomplete-implementation warning.
@goneng
goneng marked this pull request as ready for review September 20, 2026 22:04
@hannesa2
hannesa2 merged commit d4a86a9 into gitx:master Sep 21, 2026
2 checks passed
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