Search code examples
gitshellemacselisp

Emacs: why shell-command "git log" works, but "git shortlog" doesn't?


I can't figure this out. Why do these behave differently:

(shell-command "git log")
(shell-command "git shortlog")

First one works as expected: returns 0 and prints stuff to shell output buffer. Second one returns 0 but prints nothing. Why is that?

Also

  1. both git log and git shortlog work perfectly in ansi-term
  2. both git log and git shortlog give a warning but still work in shell

Solution

  • man git-shortlog

    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.

    You must explicitly provide reference to work in your case,

    Use, git shortlog HEAD instead.