webdiff icon indicating copy to clipboard operation
webdiff copied to clipboard

Use git diff for diffs

Open danvk opened this issue 3 years ago • 1 comments

  • For file diffs: difflib.js → git diff --no-index left right
  • For directory diffs: hand-rolled code → git diff --no-index --raw left right

This eliminates a bunch of code, gets us much better diffs and lots more options. The one downside is that we have to invoke git difftool with --no-symlinks. This means that you can't make changes to unstaged files after running git webdiff and reload to see the changes. This is a fundamental issue with how git diff --no-index handles symlinks, see https://public-inbox.org/git/[email protected]/t/

I also took the opportunity to update a few dependencies and plug in a system for options using .gitconfig.

Closes #129 Fixes #100 Closes #120 Fixes #7 Fixes #82 Fixes #121

danvk avatar Sep 17 '22 20:09 danvk

TODO: this chops off the last line of files w/o trailing newlines

2024: to repro, run git webdiff 12bdbcc2629086b9c253ad1e1695d38ca0763692..1400f38a40f31b4aac4a95f42d0161ade4d2ca16 in the refstudio repo and look at CollapsibleBlock.tsx. This seems to be an issue with adds.

The bug turned out to be that wc -l ignores lines without trailing newlines. I changed it to git grep -c "" and it works like a charm.

danvk avatar May 18 '23 15:05 danvk