Skip to content

Document init script behavior with multiple master remotes#2148

Merged
EliahKagan merged 1 commit intogitpython-developers:mainfrom
EliahKagan:claude/gifted-booth-e5e2b4
May 10, 2026
Merged

Document init script behavior with multiple master remotes#2148
EliahKagan merged 1 commit intogitpython-developers:mainfrom
EliahKagan:claude/gifted-booth-e5e2b4

Conversation

@EliahKagan
Copy link
Copy Markdown
Member

@EliahKagan EliahKagan commented May 10, 2026

Summary

  • Add a comment to init-tests-after-clone.sh explaining what happens when master is 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 to git checkout -b master, creating the branch at the current HEAD. The reflog built up by the subsequent git reset --hard HEAD~1 calls then traces HEAD's history instead of a remote master's. This is harmless because master is 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.sh passes
  • shellcheck init-tests-after-clone.sh passes
  • Diff is comment-only; no behavior change

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 10, 2026 01:50
@EliahKagan EliahKagan marked this pull request as draft May 10, 2026 01:50
@EliahKagan EliahKagan force-pushed the claude/gifted-booth-e5e2b4 branch from 7a03e10 to b5ae6c0 Compare May 10, 2026 01:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 when master is missing locally and multiple remotes have it.
  • Explain that the script then creates master at the current HEAD, 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.

Comment thread init-tests-after-clone.sh Outdated
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread init-tests-after-clone.sh
Copy link
Copy Markdown
Member Author

@EliahKagan EliahKagan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@EliahKagan
Copy link
Copy Markdown
Member Author

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.

@EliahKagan EliahKagan marked this pull request as ready for review May 10, 2026 02:13
@EliahKagan EliahKagan merged commit acb6d56 into gitpython-developers:main May 10, 2026
34 checks passed
@EliahKagan EliahKagan deleted the claude/gifted-booth-e5e2b4 branch May 10, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Init script makes slightly confusing reflog if multiple remotes have "master"

2 participants