python / python/cpython

patchcheck does not recognise the upstream remote in a partial clone (git remote -v appends "[blob:none]")

Open
#156,064 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

infra type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

make patchcheck fails to find the upstream remote in a partial clone (git clone --filter=blob:none ...), even when the remote is named upstream and points at https://github.com/python/cpython:

ValueError: Patchcheck was unable to find an unambiguous upstream remote, with URL matching 'https://github.com/python/cpython'. For help creating an upstream remote, see Dev Guide: https://devguide.python.org/getting-started/git-boot-camp/#cloning-a-forked-cpython-repository
Remotes found:
origin	https://github.com/ekanshul/cpython.git (fetch)

Since Git 2.37 (git/git@ef6d15ca53), git remote -v appends the object filter of a promisor remote to its fetch line:

$ git remote -v
origin	https://github.com/ekanshul/cpython.git (fetch)
origin	https://github.com/ekanshul/cpython.git (push)
upstream	https://github.com/python/cpython.git (fetch) [blob:none]
upstream	https://github.com/python/cpython.git (push)

get_git_upstream_remote() in Tools/patchcheck/patchcheck.py (from #135806) selects fetch lines with remote.endswith("(fetch)"), so the partially-cloned upstream is dropped both from the candidates and from the "Remotes found" list in the error message, which makes the message misleading too. Matching "(fetch)" anywhere on the line fixes it.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS (git 2.50.1)

Linked PRs
  • gh-156065

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

Start in Tools/patchcheck/patchcheck.py at get_git_upstream_remote(), and inspect how git remote -v output is filtered. Reproduce with a partial clone using --filter=blob:none and verify that the upstream fetch remote is detected and included in the error output when appropriate. Done means make patchcheck recognises the upstream remote despite the appended [blob:none] text; linked PR gh-156065 is already present.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.