Skip to content

adopt-project.py: execute counts a leg's commits with git rev-list --count HEAD and no --, so a leg that keeps a root file named HEAD stops execute with exit 128 after git filter-repo, before that leg is pushed #1215

Open

Description

@brettheap

_extract_leg counts a leg's kept commits with git rev-list --count HEAD in the leg's work clone, right after git filter-repo (adopt-project.py:13915 on main ef619c74). That argv has no --. When the leg tracks a file named HEAD at its root, the work tree holds that file, and git reads the argument both ways:

rev-list --count HEAD     exit=128  fatal: ambiguous argument 'HEAD': both revision and filename
rev-list --count HEAD --  exit=0
rev-parse HEAD            exit=0

Measured on git 2.43.0 by lane 1's reviewer r1180d (probe P6, in its scratch clone), while reviewing #1180, which fixed the same class of argv for the source-partial-clone walk.

What it costs:

  • git_out raises, so execute stops after git filter-repo and before that leg is pushed.
  • The line just above it reads head = git_out(["rev-parse", "HEAD"], cwd=work), so the id is already in hand.
  • Not yet measured: what an earlier leg left pushed by then, and whether check or plan would have warned.

The fix:

  • Count head, the id from the line above, and end the argv with --: ["rev-list", "--count", head, "--"].
  • Add a row: a source whose code leg keeps a root file named HEAD gets through execute with both legs pushed.

Same shape elsewhere, not measured:

  • Source.commit_count runs ["rev-list", "--count", self.commit] (adopt-project.py:2899). A file named as the commit's id would trip it.
  • shape-doctor.py passes a commit id to rev-list with no -- at about lines 5864 and 6166.

Found by lane 1 (openRepoShape-1); see #1180's review r1180d.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions