Skip to content

Git command failed (exit-code 129) unknown option: 'end-of-option' #86

Closed

Description

@rizpras

I use git-php in Lumen framework with the following code

  try{
        $git = new Git();
        $remote = env('GIT_URL').$request->code;

        $local = storage_path('repo')."/".$request->code;
        $repo = $git->open($local);
        $repo->execute("config", "user.name", "latexbki");
        $repo->execute("config", "user.email", "latex.bki@gmail.com");

        $filename = $repo->getRepositoryPath() . '/'.$request->file;
        file_put_contents($filename, $request->content);
        
        $repo->addFile($filename);
        $repo->commit("test adding notes", "--author=latexbki <latex.bki@gmail.com>");
        $repo->push(NULL, ['--repo'=>$remote]);

        return response()->json(['status'=>"success", 'message'=>"Changes pushed to remote successfully"], 200);
    }catch(\Exception $e)
    {
        $errormessage = "Draft Controller: ".$e->getMessage()." -- in line ".$e->getLine();
        return response()->json(['code'=>500, 'status'=>"error", 'message'=>$errormessage], 500);
    }

When I run the code, I get the error
Command 'git push --repo 'https://latex.bki%40gmail.com:BKI1964@git.overleaf.com/62c7951c097b4c6fdf2980b4' --end-of-options' failed (exit-code 129). error: unknown option end-of-options

I previously get the same error from addFile and I resolve it by commenting the end-of-option part.

My questions are:

  1. Is it okay if I commented the end-of-option part? The code run just fine with the option commented out
  2. Is it maybe related to the git version? For information, I am using a rather old server with git version 2.7.4

Thank you very much

Activity

  1. added a commit that references this issue on Dec 10, 2022
  2. janpecha commented on Dec 10, 2022

    @janpecha
    Member

    Hello,

    yes, it is caused by old Git version (--end-of-options is implemented in Git 2.24).

    Update this library to 4.1.0 and try use OldGitRunner, it removes --end-of-options automatically (but creates security hole):

    $git = new Git(new CzProject\GitPhp\Runners\OldGitRunner);
  3. rizpras commented on Dec 22, 2022

    @rizpras
    Author

    Thanks for the answer! I'll try to update the Git then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions