Skip to content

doctor's own fix breaks git fetch and git pull, then reports ok #63

Description

@MongLong0214

Found by cloning the repository fresh and doing exactly what doctor said, in order.

Reproduction — no editing, only following instructions

git clone https://github.com/MongLong0214/commitlore.git && cd commitlore
node dist/commitlore.mjs doctor
  warn  notes fetch refspec — origin does not fetch refs/notes/commitlore
        fix: git config --add remote.origin.fetch '+refs/notes/commitlore:refs/notes/commitlore'

git config --add remote.origin.fetch '+refs/notes/commitlore:refs/notes/commitlore'

git fetch origin   → fatal: couldn't find remote ref refs/notes/commitlore   exit 128
git pull           → fatal: couldn't find remote ref refs/notes/commitlore   exit 1

node dist/commitlore.mjs doctor
  ok    notes fetch refspec — origin fetches refs/notes/commitlore

The user's git pull is now permanently broken, and doctor says the check is ok.

An explicit (non-wildcard) refspec naming a ref the remote does not have is fatal to the entire fetch, not just that ref. origin has no refs/notes/commitlore because nothing has ever pushed one.

The fix line is wrong; a wildcard is not

+refs/notes/*:refs/notes/*                          → git fetch exit 0
+refs/notes/commitlore:refs/notes/commitlore        → git fetch exit 128

Verified both, in that order, in the same clone. A wildcard refspec matching nothing is not an error; an explicit one is.

Whether the wildcard is the right recommendation is a separate question — it fetches every notes ref, including other tools'. The alternative is to add the explicit refspec only after confirming the remote has the ref, and to tell the user to push one first otherwise.

The deeper defect is the second doctor run

This is the third instance today of the same shape:

check what it verifies what it misses
#58 validate the trailer is well-formed the record it names exists
#60 validate the message parses two records became one
this doctor the config line is present fetching actually works

doctor exists to tell a user whether their setup works. A check that reads back its own written config and calls it ok is checking that git config works, not that CommitLore does. Every doctor check that recommends a fix must verify the outcome of that fix, not its trace.

That principle belongs in the check-class model being written for #58/#60doctor is squarely in the Conservation class (needs a before and an after) and has been implemented as if it were in the Shape class.

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions