Document init script behavior with multiple master remotes#2148
Conversation
7a03e10 to
b5ae6c0
Compare
There was a problem hiding this comment.
Pull request overview
Adds in-script documentation clarifying an unintuitive git checkout master -- || git checkout -b master edge case when multiple remotes provide a master branch, so future contributors understand why master’s reflog may end up reflecting HEAD history during test initialization (Closes #2145).
Changes:
- Document how
git checkout master --can fail due to ambiguous remote-tracking branches whenmasteris missing locally and multiple remotes have it. - Explain that the script then creates
masterat the currentHEAD, affecting which history the reflog-reset sequence records (before resetting back to__testing_point__).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When `master` is locally absent and more than one remote has it, `git checkout master --` fails by default even if all remotes agree, and the script falls back to creating `master` at `HEAD`. The reflog populated by the subsequent resets then traces `HEAD`'s history rather than a remote `master`'s. This is harmless, because `master` is reset to `__testing_point__` either way, but unintuitive. Add a comment so a reader of the script does not have to discover this from a confusing run. This fixes gitpython-developers#2145. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b5ae6c0 to
0c1e409
Compare
EliahKagan
left a comment
There was a problem hiding this comment.
I didn't think of a better way to deal with this besides adding a comment. Also, I had originally thought of including this as part of some larger PR, but it doesn't really fit nicely in with any of the other forthcoming GitPython PRs I'm working on. So I'm doing it by itself. I think this at least better than not expanding the comment, and I plan to merge this once CI passes.
|
Incidentally, I decided to try to have Claude Code proceed in its default way, rather than articulating a plan first. Overall, this is faster but kind of rough: for example, the branch name is meaningless, which is something I try to avoid. I don't think the branch name is worth the noise and churn of remaking the PR, though. |
Summary
init-tests-after-clone.shexplaining what happens whenmasteris locally absent but present on more than one remote:git checkout master --refuses to pick one (even when all of the remote-tracking branches agree on a commit), and the script falls back togit checkout -b master, creating the branch at the currentHEAD. The reflog built up by the subsequentgit reset --hard HEAD~1calls then tracesHEAD's history instead of a remotemaster's. This is harmless becausemasteris reset to__testing_point__afterward, but it is unintuitive enough to be worth noting in the script itself.Closes #2145.
Test plan
sh -n init-tests-after-clone.shpassesshellcheck init-tests-after-clone.shpasses🤖 Generated with Claude Code