simonthum/git-sync

Git diff 0 should means not dirty

Closed this issue · 4 comments

git diff --no-ext-diff --quiet --exit-code || echo "|DIRTY"

I think it should be &&, because git diff return 1 if there were differences and 0 means no differences, and 1 && '|Dirty is correct.

Hi, in my tests the line executes as expected.

0 (True in shell) means no differences, so lazy evaluation will not cause the right clause to be evaluated. Not dirty.

1 (False in shell) means differences, so lazy evaluation will cause the right clause to be evaluated. This means dirty, as git diff documents.

No bug here, AFAICT. But thank for looking that close ;)

Oh! 0 (True in shell) I think this is what I mistake for...

I implemented this in JS, so it works cross-platform even users don't have git binary installed in their machine.

And this line confused me, Thank you for this explanation!

Ok, it would be great if yout sent a note when you are done, so I can link to your impl.

Hi @simonthum , I managed to refactor my JS implementation of your Git-Sync here https://github.com/linonetwo/git-sync-js

Actually, I don't really understand some of the git operations, they are so elegant, but after carefully compare my javascript to your shell script to make sure they are the same, it works fine now.