From: Junio C Hamano <gitster@pobox.com>
To: Nicolas Pitre <nico@cam.org>
Cc: Pierre Habouzit <madcoder@debian.org>,
Ingo Molnar <mingo@elte.hu>, Jeff King <peff@peff.net>,
Jakub Narebski <jnareb@gmail.com>,
Christian Couder <chriscool@tuxfamily.org>,
git@vger.kernel.org
Subject: Re: [PATCH] Invert numbers and names in the git-shortlog summary mode.
Date: Tue, 11 Dec 2007 10:09:04 -0800 [thread overview]
Message-ID: <7vr6htdry7.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LFD.0.99999.0712111032530.555@xanadu.home> (Nicolas Pitre's message of "Tue, 11 Dec 2007 10:34:01 -0500 (EST)")
Nicolas Pitre <nico@cam.org> writes:
> On Tue, 11 Dec 2007, Pierre Habouzit wrote:
> ...
>> Sometimes history hurts :) I don't think there is much we can do on a
>> short timescale. Maybe the old way can be slowly deprecated, and then
>> git-shortlog will be able to act like git-log.
>
> At least, HEAD could be assumed by default when stdin is a tty.
I'd say I agree.
-- >8 --
shortlog: default ot HEAD when standard input is a tty
Instead of warning the user that it is expecting git log output from the
standard input (and instructing to type the log from the keyboard),
default to traverse from HEAD when there is no rev parameter given.
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-shortlog.c | 5 +++--
builtin-diff.c | 14 +-------------
builtin-log.c | 5 +----
revision.c | 12 ++++++++++++
revision.h | 2 ++
5 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 90666cb..3d8d709 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -249,9 +249,10 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
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/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, "--"))
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 e1f1cf6..d375c9d 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -18,9 +18,6 @@
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);
@@ -746,7 +743,7 @@ int cmd_format_patch(int argc, const char **argv, const char *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/revision.c b/revision.c
index 2a59035..7e2f4f1 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;
diff --git a/revision.h b/revision.h
index 992e1e9..8572315 100644
--- a/revision.h
+++ b/revision.h
@@ -130,6 +130,8 @@ extern void add_object(struct object *obj,
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,
next prev parent reply other threads:[~2007-12-11 18:09 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-07 9:34 git-bisect feature suggestion: "git-bisect diff" Ingo Molnar
2007-12-07 9:58 ` Junio C Hamano
2007-12-07 10:25 ` Junio C Hamano
2007-12-07 11:21 ` Ingo Molnar
2007-12-07 19:28 ` Junio C Hamano
2007-12-07 19:46 ` Ingo Molnar
2007-12-07 21:34 ` Jeff King
2007-12-07 21:35 ` Jeff King
2007-12-07 21:44 ` Junio C Hamano
2007-12-07 21:55 ` Jeff King
2007-12-07 22:03 ` Junio C Hamano
2007-12-07 22:07 ` Jeff King
2007-12-08 2:54 ` Junio C Hamano
2007-12-08 5:36 ` Christian Couder
2007-12-08 15:29 ` Ingo Molnar
2007-12-09 5:33 ` git-bisect run make -j64 kernel/ (was Re: git-bisect feature suggestion: "git-bisect diff") Christian Couder
2007-12-12 9:43 ` Ingo Molnar
2007-12-11 9:24 ` git-bisect feature suggestion: "git-bisect diff" Ingo Molnar
2007-12-11 9:29 ` Pierre Habouzit
2007-12-11 10:13 ` Jakub Narebski
2007-12-11 11:59 ` Pierre Habouzit
2007-12-11 12:25 ` Jeff King
2007-12-11 12:33 ` Jeff King
2007-12-11 14:05 ` Ingo Molnar
2007-12-11 14:43 ` [PATCH] Invert numbers and names in the git-shortlog summary mode Pierre Habouzit
2007-12-11 14:57 ` Ingo Molnar
2007-12-11 15:24 ` Pierre Habouzit
2007-12-11 15:34 ` Nicolas Pitre
2007-12-11 18:09 ` Junio C Hamano [this message]
2007-12-11 15:48 ` Ingo Molnar
2007-12-11 16:07 ` Pierre Habouzit
2007-12-11 16:11 ` Pierre Habouzit
2007-12-11 21:13 ` Ingo Molnar
2007-12-11 22:21 ` Junio C Hamano
2007-12-11 17:58 ` Junio C Hamano
2007-12-11 10:17 ` git-bisect feature suggestion: "git-bisect diff" Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vr6htdry7.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
--cc=madcoder@debian.org \
--cc=mingo@elte.hu \
--cc=nico@cam.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).