diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-12-11 10:09:04 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-12-11 17:01:31 -0800 |
commit | 3384a2dfc12f0fecd25ecfd6bfa9ee0d82517bf2 (patch) | |
tree | d9a4d8565acee4ff9423178442f87b1efe815c14 /revision.c | |
parent | 97566ea72ea460576ccaea7b51dd32ab33e1c46c (diff) | |
download | git-3384a2dfc12f0fecd25ecfd6bfa9ee0d82517bf2.tar.gz git-3384a2dfc12f0fecd25ecfd6bfa9ee0d82517bf2.tar.xz |
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 <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/revision.c b/revision.c index 2a5903519..7e2f4f1eb 100644 --- a/revision.c +++ b/revision.c @@ -139,6 +139,18 @@ void add_pending_object(struct rev_info *revs, struct object *obj, const char *n add_pending_object_with_mode(revs, obj, name, S_IFINVALID); } +void add_head_to_pending(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 struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags) { struct object *object; |