Giter Site home page Giter Site logo

Comments (3)

fdcds avatar fdcds commented on May 5, 2024 1

Proposal how to fix this: A hunk in unified diff starts with ^@@. That line already contains all the information you need: The first number is the line the hunk starts on (irrelevant for you) and the second number (after the comma) is the size of the hunk before (-) / after (+) the changes. So from there you count the number of lines starting with (keep line), - (remove) and + (add). Then num_keep + num_remove == hunk_size_before and num_keep + num_add - num_remove == hunk_size_after.

So your state machine can be quite dump: You go into a "hunk state" once you reach ^@@ and then read lines until both equations above hold, at which point you have reached the end of the hunk. Then you can do the highlighting of that hunk, output it, leave "hunk state" and search for the next hunk.

For robustness, you should probably also stop when you find a line that does not match ^[ +-], independently of how many lines you already read (reason unknown, but you should not care why).

from delta.

fdcds avatar fdcds commented on May 5, 2024

Somehow this seems to not have worked. With git config --global diff.submodule log git diff outputs:

[...]
Submodule a/b/c a12bc..de34f:
  > Commit 2 Message
  > Commit 1 Message
[...]

With git config --global core.pager "delta --dark" I get following output:

[...]
Submodule a/b/c a12bc..de34f:
----
[...]

I.e. the changes to the commits are not displayed any longer.

It thus appears that delta still mangles lines outside the changed files, in this case also the indented changes to the submodule's commits, which is in "normal diff" format (>/<).

from delta.

dandavison avatar dandavison commented on May 5, 2024

Hi @fdcds Sorry this second bug has taken so long to fix. I can reproduce it. I notice that a workaround would be to use --file-style plain or --color-only, but I agree another fix to the parsing logic is still needed here.

from delta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.