gitgit-loggit-show

Difference between git show and git log when displaying commit ids


I need to get list of commit ids between two known commits. I used the following command:

git show --format=format:%H --quiet commitA...commitB

It works flawlessly until there is a merge commit. I.e.:

*   c36a37b
|\
| * 92187d9
* | e24d2c4
|/
* eef755e

The output is as follows:

$ git show --format=format:%H --quiet c36a37b...eef755e
c36a37b80caf2bae7b4833617443f4dfea8d8816

e24d2c4292baef4106976373ff3d01341834648d
92187d9a1002027c7d99824f2561467692bfd6b3

When I change the show command and use log instead:

$ git log --format=format:%H --quiet c36a37b...eef755e
c36a37b80caf2bae7b4833617443f4dfea8d8816
e24d2c4292baef4106976373ff3d01341834648d
92187d9a1002027c7d99824f2561467692bfd6b3

Notice there is no empty line after the first commit. I'm not fanatic about using git show over git log - I event don't remember where I got this idea from. But this extra empty line caused my program failure and I wonder if it has any special meaning.

Git version 1.9.5.


Solution

  • I don't see anything in the manual page explaining why that blank line is there. However, if you are passing the output to another program, you don't want the porcelain commands anyway, because the output formats are subject to change. The command you want is

    git rev-list c36a37b...eef755e
    

    Update: to your specific question -- does it have any meaning -- my answer is none that you can count on, because (a) it isn't mentioned in the manual page, and (b) the output of git show isn't intended to be parsed by other programs.