git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>, git@vger.kernel.org
Subject: Re: Git log of all (modifying) commands run on a repo?
Date: Thu, 8 Feb 2007 09:51:56 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0702080948240.8424@woody.linux-foundation.org> (raw)
In-Reply-To: <7vmz3p321n.fsf@assigned-by-dhcp.cox.net>



On Wed, 7 Feb 2007, Junio C Hamano wrote:
> 
> I think we are in agreement.  I showed an outright hacky one
> because I am not ready to do somewhat involved one at the end of
> the rc period.

How about this?

It makes "git reflog [show]" act as

	git log -g --pretty=oneline --abbrev-cmit

and is fairly straightforward. So you can just write

	git reflog

or 

	git reflog show

and it will show you the reflog in a nice format.

		Linus

---
 Documentation/git-reflog.txt |   17 +++++++++++++----
 builtin-log.c                |   32 ++++++++++++++++++++++++++++++++
 builtin-reflog.c             |   18 ++++++++++++------
 builtin.h                    |    1 +
 4 files changed, 58 insertions(+), 10 deletions(-)

diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt
index 1138865..bc7c987 100644
--- a/Documentation/git-reflog.txt
+++ b/Documentation/git-reflog.txt
@@ -8,13 +8,18 @@ git-reflog - Manage reflog information
 
 SYNOPSIS
 --------
-[verse]
-'git-reflog' expire [--dry-run] [--stale-fix]
-	[--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
-
+'git reflog' <subcommand> <options> 
 
 DESCRIPTION
 -----------
+The command takes various subcommands, and different options
+depending on the subcommand:
+
+[verse]
+git reflog expire [--dry-run] [--stale-fix]
+	[--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
+
+git reflog [show] [log-options]
 
 Reflog is a mechanism to record when the tip of branches are
 updated.  This command is to manage the information recorded in it.
@@ -25,6 +30,10 @@ Entries older than `expire` time, or entries older than
 tip, are removed from the reflog.  This is typically not used
 directly by the end users -- instead, see gitlink:git-gc[1].
 
+The subcommand "show" (which is also the default, in the absense of any
+subcommands) will take all the normal log options, and show the log of
+the current branch. It is basically an alias for 'git log -g --abbrev-commit
+--pretty=oneline', see gitlink:git-log[1].
 
 
 OPTIONS
diff --git a/builtin-log.c b/builtin-log.c
index 982d871..af2de54 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -11,6 +11,7 @@
 #include "log-tree.h"
 #include "builtin.h"
 #include "tag.h"
+#include "reflog-walk.h"
 
 static int default_show_root = 1;
 
@@ -181,6 +182,37 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 	return ret;
 }
 
+/*
+ * This is equivalent to "git log -g --abbrev-commit --pretty=oneline"
+ */
+int cmd_log_reflog(int argc, const char **argv, const char *prefix)
+{
+	struct rev_info rev;
+
+	git_config(git_log_config);
+	init_revisions(&rev, prefix);
+	init_reflog_walk(&rev.reflog_info);
+	rev.abbrev_commit = 1;
+	rev.verbose_header = 1;
+	cmd_log_init(argc, argv, prefix, &rev);
+
+	/*
+	 * This means that we override whatever commit format the user gave
+	 * on the cmd line.  Sad, but cmd_log_init() currently doesn't
+	 * allow us to set a different default.
+	 */
+	rev.commit_format = CMIT_FMT_ONELINE;
+	rev.always_show_header = 1;
+
+	/*
+	 * We get called through "git reflog", so unlike the other log
+	 * routines, we need to set up our pager manually..
+	 */
+	setup_pager();
+
+	return cmd_log_walk(&rev);
+}
+
 int cmd_log(int argc, const char **argv, const char *prefix)
 {
 	struct rev_info rev;
diff --git a/builtin-reflog.c b/builtin-reflog.c
index bfb169a..65b845b 100644
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
@@ -13,7 +13,7 @@
  */
 
 static const char reflog_expire_usage[] =
-"git-reflog expire [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
+"git-reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
 
 static unsigned long default_reflog_expire;
 static unsigned long default_reflog_expire_unreachable;
@@ -372,10 +372,16 @@ static const char reflog_usage[] =
 
 int cmd_reflog(int argc, const char **argv, const char *prefix)
 {
-	if (argc < 2)
-		usage(reflog_usage);
-	else if (!strcmp(argv[1], "expire"))
+	/* With no command, we default to showing it. */
+	if (argc < 2 || *argv[1] == '-')
+		return cmd_log_reflog(argc, argv, prefix);
+
+	if (!strcmp(argv[1], "show"))
+		return cmd_log_reflog(argc - 1, argv + 1, prefix);
+
+	if (!strcmp(argv[1], "expire"))
 		return cmd_reflog_expire(argc - 1, argv + 1, prefix);
-	else
-		usage(reflog_usage);
+
+	/* Not a recognized reflog command..*/
+	usage(reflog_usage);
 }
diff --git a/builtin.h b/builtin.h
index dd0e352..5108fd2 100644
--- a/builtin.h
+++ b/builtin.h
@@ -40,6 +40,7 @@ extern int cmd_grep(int argc, const char **argv, const char *prefix);
 extern int cmd_help(int argc, const char **argv, const char *prefix);
 extern int cmd_init_db(int argc, const char **argv, const char *prefix);
 extern int cmd_log(int argc, const char **argv, const char *prefix);
+extern int cmd_log_reflog(int argc, const char **argv, const char *prefix);
 extern int cmd_ls_files(int argc, const char **argv, const char *prefix);
 extern int cmd_ls_tree(int argc, const char **argv, const char *prefix);
 extern int cmd_mailinfo(int argc, const char **argv, const char *prefix);

  parent reply	other threads:[~2007-02-08 17:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-07 22:15 Git log of all (modifying) commands run on a repo? Bill Lear
2007-02-07 22:29 ` Jakub Narebski
2007-02-07 22:39   ` Bill Lear
2007-02-07 22:59     ` Jakub Narebski
2007-02-07 22:49 ` Linus Torvalds
2007-02-07 22:56   ` Junio C Hamano
2007-02-07 23:03     ` Shawn O. Pearce
2007-02-07 23:26     ` Linus Torvalds
2007-02-07 23:36       ` Junio C Hamano
2007-02-07 23:46         ` Linus Torvalds
2007-02-07 23:53           ` Jakub Narebski
2007-02-07 23:59           ` Johannes Schindelin
2007-02-08  0:05             ` Shawn O. Pearce
2007-02-08  0:26           ` Junio C Hamano
2007-02-08  0:41             ` Johannes Schindelin
2007-02-08  0:50               ` Junio C Hamano
2007-02-08  0:56                 ` Johannes Schindelin
2007-02-08 17:51                 ` Linus Torvalds [this message]
2007-02-08 18:36                   ` Johannes Schindelin
2007-02-07 22:57   ` Shawn O. Pearce
2007-02-07 23:00   ` Bill Lear
2007-02-07 23:29     ` Linus Torvalds
2007-02-07 23:31       ` Bill Lear
2007-02-07 23:02   ` Linus Torvalds
2007-02-08  8:26   ` Johannes Sixt

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=Pine.LNX.4.64.0702080948240.8424@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.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).