7

I want to get a high quality diff and I am not worried about how long it will take, e.g.

git merge --strategy-option=diff-algorithm=minimal develop

From the docs, Its not clear which one is best for which situations?

  • default, myers The basic greedy diff algorithm. Currently, this is the default.

  • minimal Spend extra time to make sure the smallest possible diff is produced.

  • patience Use "patience diff" algorithm when generating patches.

  • histogram This algorithm extends the patience algorithm to "support low-occurrence common elements".

There is a summary of the patience algorithm in another answer.

  • Is the histogram algorithm always be better than the patience algorithm since it extends it?
  • Is the minimal algorithm better than the default since it 'spends extra time'?
  • Are --strategy-option=patience and --strategy-option=diff-algorithm=patience equivalent?
Community
  • 1
  • 1
Robert
  • 35,442
  • 34
  • 158
  • 205
  • Hmm - `git merge --strategy-option=minimal develop` dons't seem to work, minimal not recognised as a strategy. – Robert May 23 '14 at 14:47
  • I think you're confusing `git diff` strategies with `git merge` strategies and their associated options. These are not the same things... – twalberg May 23 '14 at 15:22
  • @twalberg - I'm fairly sure that these options are also shared with the git merge command. http://git-scm.com/docs/git-merge – Robert May 23 '14 at 16:28
  • 2
    You need to read the section of that manual page headed "MERGE STRATEGIES". If you want to specify a different `git diff` strategy option for the default recursive merge strategy, they syntax would be `git merge --strategy-option=diff-algorithm=minimal` for example, not `git merge --strategy-option=minimal` the way you have it stated... "patience" seems to be an exception, but the others are not valid as strategy options on their own... Not entirely sure if `git merge --strategy-option=patience` and `git merge --strategy-option=diff-algorithm=patience` are completely equivalent... – twalberg May 23 '14 at 16:45
  • @twalberg - Cool thanks! Ill adjust my question. – Robert May 23 '14 at 21:27

1 Answers1

3

You should always use histogram and not worry about it. The vast majority of the time all algorithms will give the exact same results, but once in a great while there will be an XML file or a heavily edited C file with lots of curly brackets where myers and minimal will merge up meaningless repeated sections of the file and have a completely broken and unusable output with unrelated sections of code on either side of conflict sections. Both patience and histogram will handle those cases fine, but histogram runs faster. Since histogram is both the best and fastest algorithm, there isn't much reason to use anything else.

Bram Cohen
  • 549
  • 4
  • 10