Skip to main content

5.4.3 Diff Options

user option magit-diff-refine-hunk​

Whether to show word-granularity differences within diff hunks.

  • nil Never show fine differences.
  • t Show fine differences for the current diff hunk only.
  • all Show fine differences for all displayed diff hunks.

user option magit-diff-refine-ignore-whitespace​

Whether to ignore whitespace changes in word-granularity differences.

user option magit-diff-adjust-tab-width​

Whether to adjust the width of tabs in diffs.

Determining the correct width can be expensive if it requires opening large and/or many files, so the widths are cached in the variable magit-diff--tab-width-cache. Set that to nil to invalidate the cache.

  • nil Never adjust tab width. Use ‘tab-width’s value from the Magit buffer itself instead.
  • t If the corresponding file-visiting buffer exits, then use tab-width’s value from that buffer. Doing this is cheap, so this value is used even if a corresponding cache entry exists.
  • always If there is no such buffer, then temporarily visit the file to determine the value.
  • NUMBER Like always, but don’t visit files larger than NUMBER bytes.

user option magit-diff-paint-whitespace​

Specify where to highlight whitespace errors.

See magit-diff-highlight-trailing, magit-diff-highlight-indentation. The symbol t means in all diffs, status means only in the status buffer, and nil means nowhere.

  • nil Never highlight whitespace errors.
  • t Highlight whitespace errors everywhere.
  • uncommitted Only highlight whitespace errors in diffs showing uncommitted changes. For backward compatibility status is treated as a synonym.

user option magit-diff-paint-whitespace-lines​

Specify in what kind of lines to highlight whitespace errors.

  • t Highlight only in added lines.
  • both Highlight in added and removed lines.
  • all Highlight in added, removed and context lines.

user option magit-diff-highlight-trailing​

Whether to highlight whitespace at the end of a line in diffs. Used only when magit-diff-paint-whitespace is non-nil.

user option magit-diff-highlight-indentation​

This option controls whether to highlight the indentation in case it used the "wrong" indentation style. Indentation is only highlighted if magit-diff-paint-whitespace is also non-nil.

The value is an alist of the form ((REGEXP . INDENT)...). The path to the current repository is matched against each element in reverse order. Therefore if a REGEXP matches, then earlier elements are not tried.

If the used INDENT is tabs, highlight indentation with tabs. If INDENT is an integer, highlight indentation with at least that many spaces. Otherwise, highlight neither.

user option magit-diff-hide-trailing-cr-characters​

Whether to hide ^M characters at the end of a line in diffs.

user option magit-diff-highlight-hunk-region-functions​

This option specifies the functions used to highlight the hunk-internal region.

magit-diff-highlight-hunk-region-dim-outside overlays the outside of the hunk internal selection with a face that causes the added and removed lines to have the same background color as context lines. This function should not be removed from the value of this option.

magit-diff-highlight-hunk-region-using-overlays and magit-diff-highlight-hunk-region-using-underline emphasize the region by placing delimiting horizontal lines before and after it. Both of these functions have glitches which cannot be fixed due to limitations of Emacs’ display engine. For more information see https://github.com/magit/magit/issues/2758 ff.

Instead of, or in addition to, using delimiting horizontal lines, to emphasize the boundaries, you may which to emphasize the text itself, using magit-diff-highlight-hunk-region-using-face.

In terminal frames it’s not possible to draw lines as the overlay and underline variants normally do, so there they fall back to calling the face function instead.

user option magit-diff-unmarked-lines-keep-foreground​

This option controls whether added and removed lines outside the hunk-internal region only lose their distinct background color or also the foreground color. Whether the outside of the region is dimmed at all depends on magit-diff-highlight-hunk-region-functions.

user option magit-diff-extra-stat-arguments​

This option specifies additional arguments to be used alongside --stat.

The value is a list of zero or more arguments or a function that takes no argument and returns such a list. These arguments are allowed here: --stat-width, --stat-name-width, --stat-graph-width and --compact-summary. Also see the git-diff(1) manpage.