path: root/builtin-diff.c
diff options
authorJunio C Hamano <>2007-12-11 18:09:04 (GMT)
committerJunio C Hamano <>2007-12-12 01:01:31 (GMT)
commit3384a2dfc12f0fecd25ecfd6bfa9ee0d82517bf2 (patch)
treed9a4d8565acee4ff9423178442f87b1efe815c14 /builtin-diff.c
parent97566ea72ea460576ccaea7b51dd32ab33e1c46c (diff)
shortlog: default to HEAD when the standard input is a tty
Instead of warning the user that it is expecting git log output from the standard input (and waiting for the user to type the log from the keyboard, which is a silly thing to do), default to traverse from HEAD when there is no rev parameter given and the standard input is a tty. This factors out a useful helper "add_head()" from builtin-diff.c to a more appropriate place revision.c while renaming it to more descriptive name add_head_to_pending(), as that is what the function is about. Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin-diff.c')
1 files changed, 1 insertions, 13 deletions
diff --git a/builtin-diff.c b/builtin-diff.c
index 1b61599..55fb84c 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -176,18 +176,6 @@ static int builtin_diff_combined(struct rev_info *revs,
return 0;
-void add_head(struct rev_info *revs)
- unsigned char sha1[20];
- struct object *obj;
- if (get_sha1("HEAD", sha1))
- return;
- obj = parse_object(sha1);
- if (!obj)
- return;
- add_pending_object(revs, obj, "HEAD");
static void refresh_index_quietly(void)
struct lock_file *lock_file;
@@ -272,7 +260,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
if (!strcmp(arg, "--"))
else if (!strcmp(arg, "--cached")) {
- add_head(&rev);
+ add_head_to_pending(&rev);
if (!
die("No HEAD commit to compare with (yet)");