scottgonzalez / pretty-diff

colorized HTML diffs
MIT License
218 stars 27 forks source link

Does not work upon comparing files that are not versioned (non git folders) #28

Closed daformat closed 7 years ago

daformat commented 7 years ago

So, git diff works pretty much without any trouble when you pass it local files that are from in non git versioned folders. Trying to get the same result with pretty-diff is a total fail.

Here is the git diff commands I'm using on a non git folder (working and giving the same result, which is expected)

git diff --word-diff file1.html file2.html
git diff --color-words --word-diff file1.html file2.html
git diff --no-index --color-words --word-diff file1.html file2.html
git diff --no-index --color-words --word-diff -- file1.html file2.html

All of these commands perfectly produces a colored word-diff, and works on non git initialized folders: image

I get absolutely no result when trying the same thing with pretty-diff. Is there any configuration option I'm missing somewhere? I thought pretty-diff just "carried out" the args to git diff and expected to work out-of-the-box from what the README states "Simply use pretty-diff the same way you use git diff". Here is a screenshot: image

I also tried inserting "diff" between pretty-diff and the rest of the args but it returns "error: not a git repository".

scottgonzalez commented 7 years ago

I didn't know that git diff worked outside of git repositories, but I guess that makes sense. The problem was that git diff exits with a code of 1 when you do that, even though it renders the diff. Since the exit code indicates an error, pretty-diff just prints out stderr from git diff, but in this case stderr is empty.

I've updated pretty-diff to handle this odd case and release v0.6.1.

daformat commented 7 years ago

Yeah, I just got the notification and saw the 'hack' you had to pull of your hat :) Thanks for fixing this so quickly!