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

Get working tree diff #113

Open
fsevestre opened this issue Mar 26, 2017 · 1 comment
Open

Get working tree diff #113

fsevestre opened this issue Mar 26, 2017 · 1 comment

Comments

@fsevestre
Copy link

Hi guys,
I would like to retrieve a diff of the working tree but it's seems it is not possible at the moment (a simple git diff).

At first sight, I thought that the $repository->getDiff() without parameters method would do the trick, but in the end the diff command use sha^..sha as subject which is not what I expected.

I know that would be a huge BC break, but is this the wanted behavior ?

For now, I created my own DiffCommand object which don't call the addCommandSubject method and create myself the Diff object:

    $command = GitDiffCommand::getInstance($repository)->diff($commit);
    $outputLines = $repository->getCaller()->execute($command)->getOutputLines();

    $diffObjects = array();
    $splitArray = Utilities::pregSplitArray($outputLines, '/^diff --git SRC\/(.*) DST\/(.*)$/');
    foreach ($splitArray as $diffObjectLines) {
        $diffObjects[] = new DiffObject($diffObjectLines);
    }

    $diff = new Diff($repository, $diffObjects);

Is there an alternative approach ?

@vkryukov76
Copy link

Does anyone have any thoughts on this?

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

No branches or pull requests

2 participants