gitgit-diffdiffstat

Git diff stat changes when piped


If I do:

git diff --stat master

I will have something like:

 .gitignore                                           |  11 +-
 BUGS                                                 |   1 +
 Makefile                                             | 907 +++++++++++++++++++------------------------------
 README.md                                            |  55 +--

If I pipe it to a pager such as more or less, it'll change:

 .gitignore                                         |  11 +-
 BUGS                                               |   1 +
 Makefile                                           | 907 ++++++++-------------
 README.md                                          |  55 +-

What's happening?


Solution

  • The subsequent command is assuming a standard terminal width of 80 columns.

    Resize your virtual terminal to 80 columns, you'll see piping will apparently cease affecting the output.

    According Git diff help:

    [...] Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden [...]