Repository navigation
Comparing changes
Open a pull request
base repository: gitpython-developers/GitPython
base: repo-clone-options
head repository: gitpython-developers/GitPython
compare: main
- 7 commits
- 7 files changed
- 6 contributors
Commits on Nov 16, 2026
-
Merge pull request #2348 from gitpython-developers/repo-clone-options
fix(repo): protect against --reference and --reference-if-able when cloning
Configuration menu - View commit details
-
Copy full SHA for d6337df - Browse repository at this point
Copy the full SHA d6337dfView commit details
Commits on Nov 19, 2026
-
perf(diff): let the patch header regex skip to
diff --gitlines`Diff._index_from_patch_format()` finds file headers with `Diff.re_header.finditer()` over the whole patch text. The pattern started with `^`, so CPython's regex engine had no literal prefix and tried the full header pattern at every byte of the patch, including all hunk content. On large patches this scan was a large part of the Python time of `Diffable.diff(..., create_patch=True)`. The pattern now starts with the literal `diff --git` and checks the line start with the lookbehind `(?<=^diff[ ]--git)`. A match still needs `diff --git` at the start of a line, so the matches, their spans and all groups stay the same, but the engine now searches for the literal and tries the pattern only there. No Git command changes, and the Gix backend is not affected. A new test pins that `diff --git` inside hunk lines does not start a file. The change only affects speed, so no test can fail without it. Validation on macOS (Apple M5), CPython 3.12, Git 2.54.0, 15 interleaved rounds and a Mann-Whitney test: - `_index_from_patch_format()` on a 7.7 MB patch of 10,001 new files: 60.3 ms -> 45.9 ms; on a patch that adds a file of `diff --git` lines: 521 us -> 179 us. Empty, one-line, CRLF, mode-only and binary patches showed no significant change (at most +0.5%, p > 0.05, 30 rounds). CPython 3.8 and 3.15 showed the same gains and no significant slowdown. - `Commit.diff(NULL_TREE, create_patch=True)` for the 10,001 files: 166.5 ms -> 151.4 ms (-9%); GitPython 3.1.40 to `main` (343 files, 3.1 MB): 107.8 ms -> 99.9 ms (-7%); one commit of 61 files (78 KB): 18.9 ms -> 18.7 ms (-1.3%, not significant), because Git dominates small diffs. - `import git` time did not change; compiling the pattern takes about 8 us more. - Old and new code gave the same `Diff` objects and errors for 1,023,000 random, malformed and real inputs. - `pytest -m 'not net'` on the CLI backend, `test/test_diff.py` on the Gix backend, `ruff check`, `ruff format --check` and mypy pass. Agent-Model: claude-opus-5-5
Configuration menu - View commit details
-
Copy full SHA for 6bf2cca - Browse repository at this point
Copy the full SHA 6bf2ccaView commit details -
Merge pull request #2349 from g4lb/perf-diff-header-literal
perf(diff): let the patch header regex skip to `diff --git` lines
Configuration menu - View commit details
-
Copy full SHA for 57a7865 - Browse repository at this point
Copy the full SHA 57a7865View commit details
Commits on Nov 20, 2026
-
fix(index): don't keep the repository alive after
IndexFile.add()`IndexFile._iter_expand_paths()` passes `os.walk()` an `onerror` callback that re-raises the error it receives. `os.walk()` fails for every file path, so each `index.add()` of a file raised through `raise_exc()` while its frame local `e` still referenced the exception. That forms the cycle exception -> `__traceback__` -> `raise_exc` frame -> exception, and the traceback also retains the `_iter_expand_paths` generator frame, whose `self` references the `IndexFile` and its `Repo`. A `Repo` used to stage a file was therefore only released by the cyclic garbage collector instead of by reference counting. Until then its persistent `git cat-file` processes stayed alive and held repository files open, which on Windows prevents deleting the repository. `Repo.close()` hid this by forcing `gc.collect()`. Delete the local in a `finally` block before the exception propagates, which breaks the cycle without changing which errors are raised or handled. The new test stages a file with the garbage collector disabled and checks that dropping the `Repo` frees it. It fails before this change and passes after it with both the CLI and Gix backends on Windows (Python 3.14). Agent-Model: unknown Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 2d2570b - Browse repository at this point
Copy the full SHA 2d2570bView commit details -
perf(repo): stop forcing garbage collections in
Repo.close()`Repo.close()`, used by `__exit__` and `__del__`, called `gc.collect()` twice on Windows to release handles held by unreachable objects. Each call walks the whole Python heap. With 3 million live objects, closing a repository cost about 1.4 seconds in an application. A dropped `Repo` is freed by reference counting, so `__del__` paid this cost outside any automatic collection. The handles came from objects that GitPython left in reference cycles. Running the Windows test suite without any `gc.collect()` calls, and recording every failed temporary directory removal, found these sources: - The `IndexFile.add()` exception cycle fixed in the previous commit kept the repository and its `git cat-file` processes alive. It caused the observed library leaks and the file lock that `test_root_module` is marked xfail for. - `GitCmdObjectDB` reads objects only through Git, so no smmap windows or memory maps remain; `gitdb.util.mman.collect()` is kept because it is cheap. - The remaining leaks were test artifacts: `MagicMock` call records and logged exceptions retained by pytest. The test harness keeps its own collections. `close()` now only stops the persistent Git processes and releases unused gitdb memory maps. `Submodule.remove()` closes the module repository before deleting its checkout, as its other deletion paths already do, instead of collecting. The changelog documents that callers must close or release their own objects that are only reachable through reference cycles. With 3 million live objects on Windows and Python 3.14, explicit `close()` and dropping a `Repo` take about 2 ms (CLI backend) or under 0.1 ms (Gix backend) instead of about 225 ms. Without any collection in `Repo.close()` or the test harness, the full Windows suite passed with the CLI backend (2127 passed). With this change, the affected index, documentation and submodule tests pass, except for an order-dependent `test_git_submodule_compatibility` failure that also occurs on `main`. Agent-Model: unknown Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for d7fd408 - Browse repository at this point
Copy the full SHA d7fd408View commit details -
Refactor garbage collection handling in tests
Refactor garbage collection test to mock gc.collect and ensure it is not called when repo is dropped. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for a8e210b - Browse repository at this point
Copy the full SHA a8e210bView commit details -
Merge pull request #2350 from jenshnielsen/jenshnielsen/agents/gitpyt…
…hon-repo-close-gc-optimization Fix reference cycle in IndexFile._raise_exc and remove gc.collect()
Configuration menu - View commit details
-
Copy full SHA for fe74a6f - Browse repository at this point
Copy the full SHA fe74a6fView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff repo-clone-options...main