Search code examples
gitgit-diffgit-diff-tree

How to get any output from “git diff-tree --stdin”?


The man-page of git diff-tree suggests that I can do a combined diff (--cc) with a bunch of tree-objects of my choosing. You have to use the --stdin option for this. But I can’t get --stdin to output anything at all.

Example:

$ git diff-tree --stdin
a b
a b
$

Here I typed a<Space>b<Enter>Ctrl-D: It doesn’t even complain that a and b is bad input... But even with valid commit hashes and/or further options I never get any output at all.

What am I doing wrong?


Solution

  • You must provide full hashes of commit or tree objects to git diff-tree --stdin:

      $ git log -3 --pretty=%H
      a30ec5de57bbfa0c19045f3c094ec6eb4d808eb4
      f0939d956ad9ef2a00360139a6f1d1ad66accbe5
      fcdb73de293b2442231e5d8ce19f9c7d1640d186
    
      $ # lines typed on stdin are marked by ->
      $ git diff-tree --stdin
    ->fcdb73de293b2442231e5d8ce19f9c7d1640d186 a30ec5de57bbfa0c19045f3c094ec6eb4d808eb4
      fcdb73de293b2442231e5d8ce19f9c7d1640d186
      :040000 040000 e2aed2af18fb5293903a0d0b78c23e00a893394d c56666f973b77d92d52b68a14c5a26ac3508571a M    example
      :040000 000000 7cc3373fd5cad3bfe6ec261e9dcc3a9e97efe488 0000000000000000000000000000000000000000 D    prc
      :000000 040000 0000000000000000000000000000000000000000 275872c00a9f51016d2273419345b3b1d7535630 A    src
    ->275872c00a9f51016d2273419345b3b1d7535630 7cc3373fd5cad3bfe6ec261e9dcc3a9e97efe488
      275872c00a9f51016d2273419345b3b1d7535630 7cc3373fd5cad3bfe6ec261e9dcc3a9e97efe488
      :100644 100644 f26b2198fd9a0103f57a5bd828e58043507ea7b7 c52116f6d185548061058099dfe4c9e50d523aff M    chord.cpp
      :100644 100644 fcbfcdc036fb53733176ed30fd82eb261a990d5b 403e323f332a18b45dfdebfd3a8bfb1a62158bb4 M    chord.hpp
      :100644 100644 11a931f795b44cd916e1607d819eed4d5342edba 333b596faf596d73758bce949e6d86e596153126 M    polyphonic_track.cpp
      :100644 100644 7196835de2385d3f1e0b20073d327cb432ed436c f9fbbac93ef6fc19ae99113ff39a06f4df50720e M    polyphonic_track.hpp