worktree-setup warns of a pin mismatch that does not exist: it reads the superproject HEAD for a plain extern copy

Open Beginner friendly
#2,890 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, git, shell
Domain
tooling

Research direction

Start with tools/worktree-setup.sh around lines 415–416 and the fixture patterns in tools/tests/test_worktree_setup.py. Add the matching-pin plain-copy case described in the issue and run that test to confirm it fails with the current rev-parse lookup. Done means matching pins produce no warning and differing pins produce one warning.

Written by the indexing model from the issue text.

Description

Evidence at a852ca694

tools/worktree-setup.sh warns that a branch pins a submodule at a different commit than the build checkout has, and it reads the build checkout's commit in the wrong place:

  • tools/worktree-setup.sh:415 reads this branch's pin: mine=$(git ls-tree HEAD "extern/$d" ...). That is the pin, a commit in the superproject's tree.
  • tools/worktree-setup.sh:416 reads the build checkout's commit: theirs=$(git -C "$fill_from/extern/$d" rev-parse HEAD ...).
  • An extern/<d> copy that is not its own repository (the copy just worktree-setup makes; it has no .git) has no HEAD of its own. git -C then reports the enclosing repository's HEAD. Measured in this worktree: git ls-tree HEAD extern/minhook gives 1e9ad1eb42db, and git -C extern/minhook rev-parse HEAD gives 5fc77e1e9f79 (the superproject's HEAD); extern/breakpad and extern/lss give the same enclosing HEAD.
  • So theirs is never a pin, and the warning fires whenever the build checkout's copy is a plain copy and the branch's pin differs from the superproject's HEAD.

Not shown

  • Whether every build checkout's extern copies are plain. Measured here, in one worktree, not in the build checkout itself.
  • Whether a real submodule checkout (with its own .git) reports the pin correctly under rev-parse. The fix below reads the pin from the build checkout's tree, which does not depend on that.

Falsifier

With a build checkout whose superproject pins the same extern commits as the branch, tools/worktree-setup.sh prints no line beginning warning: this branch pins. At a852ca694 it prints one for each extern copy whose pin differs from the superproject's HEAD.

Work

  1. Test first, in tools/tests/test_worktree_setup.py: a fixture whose build checkout pins an extern commit equal to the branch's pin, with a plain copy under extern/, prints no pin warning. Red at a852ca694.
  2. tools/worktree-setup.sh: read the build checkout's pin with git -C "$fill_from" ls-tree HEAD "extern/$d" (the same form as line 415), and warn only when the two pins differ.
  3. Mutant: restore the rev-parse HEAD form; the test fails with the false warning. Restore the fix; it passes.
  4. Proof: the setup run in a fixture with matching pins prints nothing about pins; with differing pins it prints the warning once.
Dominant language
C++
Stars
3
Forks
5
Avg merge
4h 37m
Merged PRs (30d)
524

Getting set up

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.

More from EchoTools/nevr-runtime

All issues in EchoTools/nevr-runtime

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.