Skip to contentSkip to conversation

git shortlog vs. stdin

DISCUSSION Andreas Krey 2 participants 2 messages Nov 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi all,

I observed a strange an unexpected behaviour in 'git shortlog'.

When in git.git:

$ git shortlog -sn | wc
   1441    4493   31477

but with input redirected:

$ git shortlog -sn </dev/null | wc
      0       0       0

--no-pager expectedly doesn't help.

Observed with 2.6.2 and 2.10.0-rc1.

I originally stumbled over this while trying something like

$ ls z* | while read name rest; do
  echo "$name" ====; git --no-pager shortlog | tail -4; done

where it also essentially terminates the while loop, presumably by eating the stdin to the loop.

Bug or feature?

- Andreas

Signature · 3 lines
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
#1 lore raw
Quoted 1 line · Andreas Krey

Bug or feature?

Documented feature, but you're holding it wrong ;)

If no revisions are passed on the command line and either standard input is not a terminal or there is no current branch, git shortlog will output a summary of the log read from standard input, without reference to the current repository.

(Note that you can use shortlog ala "git log --pretty=short | git shortlog")

Signature · 1 line
Christian Neukirchen  <[email protected]>  http://chneukirchen.org