Skip to content

Fix checking out branch names with / chars#106

Closed
docwhat wants to merge 1 commit intostefanzweifel:masterfrom
docwhat:pr/complex-branches
Closed

Fix checking out branch names with / chars#106
docwhat wants to merge 1 commit intostefanzweifel:masterfrom
docwhat:pr/complex-branches

Conversation

@docwhat
Copy link
Copy Markdown
Contributor

@docwhat docwhat commented Oct 10, 2020

If a branch has a file-path looking name, then git checkout
can get confused. git switch won't.

If a branch has a file-path looking name, then `git checkout`
can get confused. `git switch` won't.
@stefanzweifel
Copy link
Copy Markdown
Owner

@docwhat Can you give an example of a „file-path looking name“? You mean something like „git checkout update-entrypoint.sh“?

Unfortunately the testsuite isn‘t complete yet, so I will have to test such stuff manually. I remember that „git switch“ somehow didn‘t work a few months ago on GitHub Action.

@stefanzweifel
Copy link
Copy Markdown
Owner

This is a weird problem.
In 2019, there was an issue discussing the same problem. However in v2.1.0 this was fixed. (#6 (comment))

I could still reproduce the error and open #108. Just calling git fetch seems to solve the problem.
(I didn't use git switch as I'm not entirely sure if that could break the workflow of others)

@stefanzweifel
Copy link
Copy Markdown
Owner

The mentioned PR #108 has been merged. I will tag a new version soon.

As mentioned, I might switch to git switch at a future date after making sure the Action still works in all possible trigger combinations.

@docwhat
Copy link
Copy Markdown
Contributor Author

docwhat commented Oct 12, 2020

@docwhat Can you give an example of a „file-path looking name“? You mean something like „git checkout update-entrypoint.sh“?

git checkout pr/complex-branches

If you need to stick to using checkout, then the correct syntax is:

git checkout pr/complex-branches --

You may have seen this error message:

fatal: ambiguous argument 'pr/complex-branches': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

docwhat added a commit to docwhat/git-auto-commit-action that referenced this pull request Oct 12, 2020
If git can't automatically figure out if the argument is a branch or
a path, it will need to be told explicitly by using `--`:

    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'

Fixes: stefanzweifel#106
@docwhat docwhat deleted the pr/complex-branches branch October 12, 2020 14:36
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