Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-pr-merge: Fix ambiguous git rev-list invocation #34

Merged
merged 2 commits into from
Jan 6, 2024
Merged

Conversation

camh-
Copy link
Member

@camh- camh- commented Jan 6, 2024

Add a -- to the end of git rev-list to ensure it works unambiguously
when the feature branch name is the same as a file in the root of the repo.

This failed with:

$ git rev-list --count firebase '^main'
fatal: ambiguous argument 'firebase': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

where firebase was the branch name and also a top-level directory.

While we're here, make the script a little more robust by using git switch
instead of git checkout, which can have the same branch/filename ambiguity.

Also use long options for git/gh commands for clarity.

Add a `--` to the end of `git rev-list` to ensure it works unambiguously
when the feature branch name is the same as a file in the root of the
repo.

This failed with:

    $ git rev-list --count firebase '^main'
    fatal: ambiguous argument 'firebase': both revision and filename
    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'

where `firebase` was the branch name and also a top-level directory.
Use long options for all `git` and `gh` options, and change the use of
`git checkout` to `git switch`, as `checkout` can be ambiguous with
branches and filenames. `switch` is not ambiguous as it deals only with
switching branches and not checking out individual files.
@camh- camh- requested a review from juliaogris January 6, 2024 05:02
Copy link
Member

@juliaogris juliaogris left a comment

Choose a reason for hiding this comment

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

I like this a lot!
🫒

@camh- camh- merged commit a573bde into master Jan 6, 2024
1 check passed
@camh- camh- deleted the fix-ambig branch January 6, 2024 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants