simonthum / git-sync

Safe and simple one-script git synchronization
773 stars 99 forks source link

Git diff 0 should means not dirty #19

Closed linonetwo closed 4 years ago

linonetwo commented 4 years ago

https://github.com/simonthum/git-sync/blob/2ca0c0253563fb44330c3f95783f4a1cbf1fec35/git-sync#L96

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

simonthum commented 4 years ago

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 ;)

linonetwo commented 4 years ago

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!

simonthum commented 4 years ago

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

linonetwo commented 3 years ago

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.