5

I want to use the '--compaction-heuristic' option in my global git config file. It's an option of the git log command:

--compaction-heuristic

--no-compaction-heuristic

These are to help debugging and tuning an experimental heuristic (which is off by default) that shifts the hunk boundary in an attempt to make the resulting patch easier to read.

The git config documentation suggests adding config settings like this example:

git config --global core.editor emacs

There doesn't appear to be anything in the git log documentation that states what this config value should be - so what is it and where would I find the specification that explains the format of the line:

git config --global [magic to enable compaction-heuristic here]

This git feature has now been removed anyway

Community
  • 1
  • 1
Neil Trodden
  • 4,724
  • 6
  • 35
  • 55

3 Answers3

10

It seems to be an option under diff.

git config --global diff.compactionHeuristic true

BTW this is an option of git diff.

Reference (diff config): https://github.com/git/git/blob/5580b271af518bae30148edfd42cc8459d8da384/Documentation/diff-config.txt#L169-L172

James Chen
  • 10,794
  • 1
  • 41
  • 38
2

According to this blog post:

This new heuristic is still experimental, and may change in the future, or even become the default. For now, you can enable it with the --compaction-heuristic option on the command line, or by setting diff.compactionHeuristic in your git config.

If you prefer, you can also create an alias for the git log command with your favorite flags:

git config --global alias.log1 "log --decorate=short --oneline --compaction-heuristic"

And use your new alias:

git log1
everton
  • 7,579
  • 2
  • 29
  • 42
1

Update Git 2.12 Q1 2017: the compactionHeuristic option is gone.
See "New git diff compaction heuristic isn't working".
Update Git 2.14 Q3 2017: the indent heuristic is now the default one.


Original answer (for Git 2.9 to 2.11, mid_2016)

Note: with Git 2.9.X/Git 2.10 (Q3 2016), the compactionHeuristic option will also be available for git add --interactive.

See commit 46e3d17 (16 Jun 2016) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 054d949, 06 Jul 2016)

add--interactive: respect diff.compactionHeuristic

"git add -i/-p" learned to honor diff.compactionHeuristic experimental knob, so that the user can work on the same hunk split as "git diff" output.

We use plumbing to generate the diff, so it doesn't automatically pick up UI config like compactionHeuristic.
Let's forward it on, since interactive adding is porcelain.

Note that we only need to handle the "true" case. There's no point in passing --no-compaction-heuristic when the variable is false, since nothing else could have turned it on.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250