Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Very informative answer! Thank you torek. You said we like the instructions as direct and close to what the human actually did. But why didn't git generate the instructions like remove one blank line -> add a line a -> keep one blank line as-is -> remove the weird line b -> and last add a normal final line b? In my opinion, I think this one is more close to what I did, and it as short as the previous one. Commented Sep 15, 2021 at 7:04
  • This is where Git has some tunables: the Myers algorithm can be run in various directions and when you do that, the blank lines that match get chosen sort of randomly. Git will, after-the-fact, sometimes try to move matched sections up or down so that blank lines match, instead of } lines. In your particular case, this could make things better, or worse, depending on what you wanted. The --indent-heuristic is the one that controls whether Git does this shuffling of blank line matching. It's not perfect, and defaults to enabled, so try disabling it. Commented Sep 15, 2021 at 7:07
  • I don't understand git will sometimes try to move matched sections up or down so that blank lines match, instead of } lines. Could you give some examples? By the way, I disabling this by using --no-indent-heuristic, but the instructions set were not changed. Commented Sep 15, 2021 at 7:31
  • That's more of a general comment, really: Git synchronizes on lines that humans find irritating in some way, so the indent-heuristic code (which is still a bit experimental) is an attempt to make its instructions match human expectations better. In your case, it doesn't seem to make any difference. Commented Sep 15, 2021 at 7:40