--end-of-options is not supported on git 2.35.1 and 2.25.1
In Commit 5e82d5479da5f16d37a915de4ec55e1ac78de733 you have added the option --end-of-options to every command.
In theory this should just work and also the documentation 2.35.1 and 2.25.1 mention this option.
But on both versions specifically the latest for ubuntu 20.04 and 2.35.1 as it's used on Ubuntu 20.04 in github actions always fail for me with the --end-of-options option enabled.
user@machine:~/testrepo$ git checkout --end-of-options test
error: pathspec '--end-of-options' did not match any file(s) known to git
error: pathspec 'test' did not match any file(s) known to git
user@machine:~/testrepo$ git checkout test
Switched to branch 'test'
user@machine:~/testrepo$ git --version
git version 2.25.1
The above is from my server running ubuntu 20.04 with latest version of git, the exact same behaviour happens in github actions for me.
Edit: fixed wrong link
Whats even weirder is that your pipeline also runs on ubuntu-latest but here it seems to work.
For now i've reverted back to v4.0.2 of git-php.
My usecase does indeed includes user input but it's only used by admins of the system an not regular users, so not running the --end-of-options option is no problem for me.
Hi, thanks for report! I tried fix it in version 4.0.4. Please try if it solves issue.
Thank you very much. Will try it tomorrow morning at work
The update has worked perfectly. Thank You!
@janpecha It works for the checkout, but isn't the issue the same for all the other commands as well?
As example, a git push done in a GitHub Action run: https://github.com/composer-wordpress/.github/runs/6180460214?check_suite_focus=true#step:8:21
@janpecha It works for the checkout, but isn't the issue the same for all the other commands as well? As example, a
git pushdone in a GitHub Action run: https://github.com/composer-wordpress/.github/runs/6180460214?check_suite_focus=true#step:8:21
Yep for me too. Wanted to report it but github had massive problems that day and i simply forgot.
The --end-of-options option doesn't seem to work for me anywhere.
Currently my pipelines fails with git pull branch_name --end-of-options origin
@flopana @LeoColomb Hi, how you call pull() method? Try use
$repo->pull(['origin', 'branch_name']);
@janpecha I don't pull anything on my side. See my usage here: https://github.com/roots/wordpress-packager/blob/2f1e7ed756bad215c5f1a1c71ca89c59185fb06e/src/Target.php#L68-L82
@LeoColomb sorry, I overlooked it :) try $this->gitRepo->push(['origin', "refs/tags/{$version}"]);
@janpecha Ok, yes, I see what you mean. Just one concern, this is passing array to an argument expected to be string.
https://github.com/czproject/git-php/blob/8a84f699216eb3aae5ee6e05bcd9fb79c9351355/src/GitRepository.php#L474-L485
So I guess, it would be "better" to actually do:
$this->gitRepo->push("origin refs/tags/{$version}");
Not a big fan, but should work, right?
I just changed PHPDoc for this methods - https://github.com/czproject/git-php/commit/24f4e51cc536a723b7838686284d1c21c6de088b#diff-a6f1a39ec7e0b5e21136926e7fa3b9700988e97d15b860a2f6d48a655e2de571. It accepts string[] too.
All good, the suggested change fixes the runs, and it actually makes sense. Thanks @janpecha!
~Btw it's still some entries in the Git class too: https://github.com/czproject/git-php/blob/24f4e51cc536a723b7838686284d1c21c6de088b/src/Git.php~
@zerkms Hi, what do you mean?
~Sorry, I meant that $git->cloneRepository(...) still fails with error: unknown option 'end-of-options' too when used like this:~
return (new Git())->cloneRepository($url, $path, ['--recurse-submodules']);
UPD: oh I understand now, I run it in a container with a quite old git (2.17), that's why it fails. My apologies.
Since 4.0.3 I'm having a problem with the push command.
Looks like in https://github.com/czproject/git-php/commit/5e82d5479da5f16d37a915de4ec55e1ac78de733 you swapped from
$this->run('push', $remote, $params);
to
$this->run('push', $params, '--end-of-options', $remote);
This results in the following command which return an error as the "remote" (origin) should be placed after the GIT command (push):
git push '<branch_name>' -u --end-of-options origin
fatal: '<branch_name>' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If you run the command with the right order you have no problem:
git push origin '<branch_name>' -u --end-of-options
Everything up-to-date
Hello, how you call push() method? Try use $repo->push(['origin', 'branch-name], ['-u']);
Yes, can do what you say or also $repo->push(null, ['origin', $branch, '-u']); and it works, but I understand this is a hack as the method signature is public function push($remote = NULL, array $options = NULL).
Previously I was using it like this $repo->push('origin', [$branch, '-u']);. Maybe I was not using it properly and the branch is intended to go in the $remote parameter instead of the $options as you propose?
Created PR to check git version and remove --end-of-options option for git < 2.24