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

git diff #1754

Open
dalduba opened this issue Apr 23, 2023 · 7 comments
Open

git diff #1754

dalduba opened this issue Apr 23, 2023 · 7 comments

Comments

@dalduba
Copy link

dalduba commented Apr 23, 2023

Is there a chance that "git diff" will be implemented?

@dalduba
Copy link
Author

dalduba commented Apr 23, 2023

The case is:
Edit some heavy data in a browser, send only diff to the server when saving.

@jcubic
Copy link
Contributor

jcubic commented Apr 23, 2023

No, it will never be implemented because it requires a Diff library and it's out of scope. You can use Diff library of your choice (like jsDiff) and implement git diff yourself.

Check my project where I've added git diff without any issues using existing API, even before version 1.0

https://github.com/jcubic/git/blob/master/js/main.js#L842

@dalduba
Copy link
Author

dalduba commented Apr 23, 2023

No, it will never be implemented because it requires a Diff library and it's out of scope. You can use Diff library of your choice (like jsDiff) and implement git diff yourself.

Check my project where I've added git diff without any issues using existing API, even before version 1.0

https://github.com/jcubic/git/blob/master/js/main.js#L842

Thanks for your reply. Could you suggest a library for "git apply" implementation on js?

@dalduba
Copy link
Author

dalduba commented Apr 23, 2023

Found, that jsdiff has Api for applying patches too.

But seems that jsDiff works only with text. May be you know solutions for binary data?

@jcubic
Copy link
Contributor

jcubic commented Apr 23, 2023

I don't think that you can diff binary data in canonical git

@dalduba
Copy link
Author

dalduba commented Apr 23, 2023

"--binary" key enables binary patches generation
https://superuser.com/a/1567733

@jcubic
Copy link
Contributor

jcubic commented Apr 24, 2023

You will need to write your own library in JavaScript to create binary patches. But the git source code is Open Source so you can look at how it was implemented and translate that into JavaScript.

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