threads / discuss / 44486

git shortlog vs. stdin

Subject: git shortlog vs. stdin

## tl;dr

2 messages between Nov 15, 2016 and Nov 15, 2016.

replies: 1people: 2as markdown or json

Andreas Krey· Nov 15, 2016, 13:04 UTC · lore
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
-- 
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
Christian Neukirchen· Nov 15, 2016, 13:39 UTC · re: Andreas Krey · lore

Re: git shortlog vs. stdin

Andreas Krey <a.krey@gmx.de> writes:
> 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")
-- 
Christian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org

← back to recent threads