summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 97566ea)
raw | patch | inline | side by side (parent: 97566ea)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 11 Dec 2007 18:09:04 +0000 (10:09 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 12 Dec 2007 01:01:31 +0000 (17:01 -0800) |
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>
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>
builtin-diff.c | patch | blob | history | |
builtin-log.c | patch | blob | history | |
builtin-shortlog.c | patch | blob | history | |
revision.c | patch | blob | history | |
revision.h | patch | blob | history |
diff --git a/builtin-diff.c b/builtin-diff.c
index 1b615991e1fc6aaa329811cc9f7b615e20b00917..55fb84c730e4141bdb53fec6602a2bdafc99f8fd 100644 (file)
--- a/builtin-diff.c
+++ b/builtin-diff.c
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;
if (!strcmp(arg, "--"))
break;
else if (!strcmp(arg, "--cached")) {
- add_head(&rev);
+ add_head_to_pending(&rev);
if (!rev.pending.nr)
die("No HEAD commit to compare with (yet)");
break;
diff --git a/builtin-log.c b/builtin-log.c
index e1f1cf67143721933010065130adaba8723b272b..d375c9dbf9759d9ddc8a0029bc5803057e5f117d 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
static int default_show_root = 1;
static const char *fmt_patch_subject_prefix = "PATCH";
-/* this is in builtin-diff.c */
-void add_head(struct rev_info *revs);
-
static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
{
int plen = strlen(prefix);
* does not have.
*/
rev.pending.objects[0].item->flags |= UNINTERESTING;
- add_head(&rev);
+ add_head_to_pending(&rev);
}
/*
* Otherwise, it is "format-patch -22 HEAD", and/or
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 90666cbd78732c15566fa8050e666999615b8354..3d8d7094ab8f85f557cf3bd58e408c8ab4272f08 100644 (file)
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
read_mailmap(&mailmap, ".mailmap", &common_repo_prefix);
+ /* assume HEAD if from a tty */
+ if (!rev.pending.nr && isatty(0))
+ add_head_to_pending(&rev);
if (rev.pending.nr == 0) {
- if (isatty(0))
- fprintf(stderr, "(reading log to summarize from standard input)\n");
read_from_stdin(&list);
}
else
diff --git a/revision.c b/revision.c
index 2a59035192baec8265acccf8b5d00aa7b2db4dd7..7e2f4f1eb5090588fc6515b78d39b7c7a4eda00d 100644 (file)
--- 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;
diff --git a/revision.h b/revision.h
index 992e1e9dd57eac528c3ecaf09987593d525da611..8572315954d1fde8c36c426d66c665534c22d1f2 100644 (file)
--- a/revision.h
+++ b/revision.h
extern void add_pending_object(struct rev_info *revs, struct object *obj, const char *name);
+extern void add_head_to_pending(struct rev_info *);
+
enum commit_action {
commit_ignore,
commit_show,