libgit2 / libgit2/pygit2

Noob question: Why patch accepted by git not accepted by libgit2/pygit2?

Open
#1,235 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

Hi:

this is my raw diff:

diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake
--- a/llvm/cmake/modules/FindZ3.cmake
+++ b/llvm/cmake/modules/FindZ3.cmake
@@ -75,7 +75,7 @@ unset(Z3_VERSION_STRING)
 
 # First, try to check it dynamically, by compiling a small program that
 # prints Z3's version
-if(Z3_INCLUDE_DIR AND Z3_LIBRARIES)
+if(Z3_INCLUDE_DIR AND Z3_LIBRARIES AND NOT CMAKE_CROSSCOMPILING)
   # We do not have the Z3 binary to query for a version. Try to use
   # a small C++ program to detect it via the Z3_get_version() API call.
   check_z3_version(${Z3_INCLUDE_DIR} ${Z3_LIBRARIES})

this is the repo/tag I'm trying to apply to: apple/llvm#swift-5.9-RELEASE

However:

git apply G5664b56043f1f6a838183e74275bfee389fea177.diff

works as intended, yet :

patch_content: str = patchPath.read_text()
patch: Diff = Diff.parse_diff(patch_content)
if (repo.applies(patch,raise_error=True)):
    repo.apply(patch)

results in:

hunk at line 75 did not apply

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the discrepancy using the provided diff against apple/llvm-project at swift-5.9-RELEASE. Compare git apply with Diff.parse_diff followed by repo.applies(..., raise_error=True) and repo.apply(...), then inspect the relevant libgit2/pygit2 patch-application behavior. Done means identifying why the hunk differs and documenting or correcting the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.