[PR #2972] [MERGED] fix(git_compat): harden pygit2 fallback path; prefer system git when available #2918

Closed
opened 2026-10-28 21:13:40 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/ComfyUI-Manager/pull/2972
Author: @Kosinkadink
Created: 6/10/2026
Status: ✅ Merged
Merged: 6/10/2026
Merged by: @ltdrdata

Base: manager-v4 ← Head: fix/pygit2-ignore-global-git-config


📝 Commits (4)

  • 498e896 fix(git_compat): ignore global git config in pygit2 backend
  • 222ae16 fix(git_compat): preserve corporate http.proxy in pygit2 backend
  • 4825d1d fix(git_compat): stop rewriting repo remotes on disk under pygit2 backend
  • 3119270 fix(git_compat): fetch SSH-origin repos via in-memory anonymous HTTPS

📊 Changes

1 file changed (+87 additions, -6 deletions)

View changed files

📝 comfyui_manager/common/git_compat.py (+87 -6)

📄 Description

Summary

Hardens the pygit2 fallback path in git_compat.py. Paired with Comfy-Org/Comfy-Desktop#1038, which is the actual fix for the Desktop update/migration failure (Comfy-Desktop#1036).

Targets manager-v4 (not shipped on main yet).

Context

The bundled pygit2/libgit2 honors the user's global git config but ships HTTPS-only (no SSH transport). A global insteadOf rewrite (https://github.com/ ? git@github.com:) makes pygit2 fetch/clone fail with authentication required but no callback set.

Manager's backend selection already does the right thing and is unchanged here:

USE_PYGIT2 = (CM_USE_PYGIT2 == '1')   # only when explicitly forced
if not USE_PYGIT2:
    try: git --version                 # probe system git via GitPython
    except: USE_PYGIT2 = True          # pygit2 only when system git is absent

Since Comfy-Desktop#1038 stops forcing CM_USE_PYGIT2, Manager now prefers system git (GitPython) whenever it's present - which honors the user's full config (insteadOf, proxy, ssh keys, credential helpers) and sidesteps the bug entirely. There's no real reason to prefer pygit2 when system git exists, so we don't.

What this PR changes (fallback path only)

pygit2 is now reached only as a no-system-git fallback (or when a developer sets COMFY_FORCE_PYGIT2=1). To keep that path robust:

  • Ignore system/global/XDG git config for libgit2 ops (in-memory search_path blanking). Protects the no-git box that still has a stray ~/.gitconfig with an insteadOf rewrite (e.g. from GitHub Desktop or synced dotfiles), which would otherwise reproduce the identical failure.
  • Preserve corporate http.proxy - snapshot it before blanking and pass it explicitly to clone/fetch, so config blanking doesn't strip a corporate proxy.

All changes live inside the if USE_PYGIT2: path, so they are inert whenever system git is available.

Not destructive

Removed the earlier on-disk remote-URL rewrite (_normalize_remote_urls): persistently rewriting a repo's stored origin is risky if interrupted and unnecessary given the config blanking. Everything here is in-memory only.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/ComfyUI-Manager/pull/2972 **Author:** [@Kosinkadink](https://github.com/Kosinkadink) **Created:** 6/10/2026 **Status:** ✅ Merged **Merged:** 6/10/2026 **Merged by:** [@ltdrdata](https://github.com/ltdrdata) **Base:** `manager-v4` ← **Head:** `fix/pygit2-ignore-global-git-config` --- ### 📝 Commits (4) - [`498e896`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/498e896472b030525d8d761824ab5a23bef50828) fix(git_compat): ignore global git config in pygit2 backend - [`222ae16`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/222ae16b96d651fe578242f5bb492f3a792816e0) fix(git_compat): preserve corporate http.proxy in pygit2 backend - [`4825d1d`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/4825d1d3695e37ee2000c8f35a02e5c9c04bd5de) fix(git_compat): stop rewriting repo remotes on disk under pygit2 backend - [`3119270`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/3119270efbe553461fe6a9c028d9b8451b118ff2) fix(git_compat): fetch SSH-origin repos via in-memory anonymous HTTPS ### 📊 Changes **1 file changed** (+87 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `comfyui_manager/common/git_compat.py` (+87 -6) </details> ### 📄 Description ## Summary Hardens the **pygit2 fallback path** in `git_compat.py`. Paired with Comfy-Org/Comfy-Desktop#1038, which is the actual fix for the Desktop update/migration failure (Comfy-Desktop#1036). > Targets `manager-v4` (not shipped on `main` yet). ### Context The bundled pygit2/libgit2 honors the user's global git config but ships **HTTPS-only (no SSH transport)**. A global `insteadOf` rewrite (`https://github.com/` ? `git@github.com:`) makes pygit2 fetch/clone fail with `authentication required but no callback set`. Manager's backend selection already does the right thing and is **unchanged** here: ``` USE_PYGIT2 = (CM_USE_PYGIT2 == '1') # only when explicitly forced if not USE_PYGIT2: try: git --version # probe system git via GitPython except: USE_PYGIT2 = True # pygit2 only when system git is absent ``` Since Comfy-Desktop#1038 stops forcing `CM_USE_PYGIT2`, Manager now **prefers system git (GitPython) whenever it's present** - which honors the user's full config (`insteadOf`, proxy, ssh keys, credential helpers) and sidesteps the bug entirely. There's no real reason to prefer pygit2 when system git exists, so we don't. ### What this PR changes (fallback path only) pygit2 is now reached only as a no-system-git fallback (or when a developer sets `COMFY_FORCE_PYGIT2=1`). To keep that path robust: - **Ignore system/global/XDG git config** for libgit2 ops (in-memory `search_path` blanking). Protects the no-git box that still has a stray `~/.gitconfig` with an `insteadOf` rewrite (e.g. from GitHub Desktop or synced dotfiles), which would otherwise reproduce the identical failure. - **Preserve corporate `http.proxy`** - snapshot it before blanking and pass it explicitly to clone/fetch, so config blanking doesn't strip a corporate proxy. All changes live inside the `if USE_PYGIT2:` path, so they are inert whenever system git is available. ### Not destructive Removed the earlier on-disk remote-URL rewrite (`_normalize_remote_urls`): persistently rewriting a repo's stored `origin` is risky if interrupted and unnecessary given the config blanking. Everything here is in-memory only. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-28 21:13:40 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/ComfyUI-Manager#2918
No description provided.