@matheusbsbs / matheus-bagliano / commits / cf39f54efc
Fork 0

git reflog show

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. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Feb 8, 2007 at 09:51 UTC cf39f54efc6ac45f9ef5319103a94d5afa75910e
4 files changed +58 -10
Documentation/git-reflog.txt
+13 -4
@@ -8,13 +8,18 @@ git-reflog - Manage reflog information
8
9 SYNOPSIS
10 --------
11 -[verse]
12 -'git-reflog' expire [--dry-run] [--stale-fix]
13 - [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
14 -
11 +'git reflog' <subcommand> <options>
12
13 DESCRIPTION
14 -----------
15 +The command takes various subcommands, and different options
16 +depending on the subcommand:
17 +
18 +[verse]
19 +git reflog expire [--dry-run] [--stale-fix]
20 + [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
21 +
22 +git reflog [show] [log-options]
23
24 Reflog is a mechanism to record when the tip of branches are
25 updated. This command is to manage the information recorded in it.
@@ -25,6 +30,10 @@ Entries older than `expire` time, or entries older than
30 tip, are removed from the reflog. This is typically not used
31 directly by the end users -- instead, see gitlink:git-gc[1].
32
33 +The subcommand "show" (which is also the default, in the absense of any
34 +subcommands) will take all the normal log options, and show the log of
35 +the current branch. It is basically an alias for 'git log -g --abbrev-commit
36 +--pretty=oneline', see gitlink:git-log[1].
37
38
39 OPTIONS
builtin-log.c
+32
@@ -11,6 +11,7 @@
11 #include "log-tree.h"
12 #include "builtin.h"
13 #include "tag.h"
14 +#include "reflog-walk.h"
15
16 static int default_show_root = 1;
17
@@ -181,6 +182,37 @@ int cmd_show(int argc, const char **argv, const char *prefix)
182 return ret;
183 }
184
185 +/*
186 + * This is equivalent to "git log -g --abbrev-commit --pretty=oneline"
187 + */
188 +int cmd_log_reflog(int argc, const char **argv, const char *prefix)
189 +{
190 + struct rev_info rev;
191 +
192 + git_config(git_log_config);
193 + init_revisions(&rev, prefix);
194 + init_reflog_walk(&rev.reflog_info);
195 + rev.abbrev_commit = 1;
196 + rev.verbose_header = 1;
197 + cmd_log_init(argc, argv, prefix, &rev);
198 +
199 + /*
200 + * This means that we override whatever commit format the user gave
201 + * on the cmd line. Sad, but cmd_log_init() currently doesn't
202 + * allow us to set a different default.
203 + */
204 + rev.commit_format = CMIT_FMT_ONELINE;
205 + rev.always_show_header = 1;
206 +
207 + /*
208 + * We get called through "git reflog", so unlike the other log
209 + * routines, we need to set up our pager manually..
210 + */
211 + setup_pager();
212 +
213 + return cmd_log_walk(&rev);
214 +}
215 +
216 int cmd_log(int argc, const char **argv, const char *prefix)
217 {
218 struct rev_info rev;
builtin-reflog.c
+12 -6
@@ -13,7 +13,7 @@
13 */
14
15 static const char reflog_expire_usage[] =
16 -"git-reflog expire [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
16 +"git-reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
17
18 static unsigned long default_reflog_expire;
19 static unsigned long default_reflog_expire_unreachable;
@@ -372,10 +372,16 @@ static const char reflog_usage[] =
372
373 int cmd_reflog(int argc, const char **argv, const char *prefix)
374 {
375 - if (argc < 2)
376 - usage(reflog_usage);
377 - else if (!strcmp(argv[1], "expire"))
375 + /* With no command, we default to showing it. */
376 + if (argc < 2 || *argv[1] == '-')
377 + return cmd_log_reflog(argc, argv, prefix);
378 +
379 + if (!strcmp(argv[1], "show"))
380 + return cmd_log_reflog(argc - 1, argv + 1, prefix);
381 +
382 + if (!strcmp(argv[1], "expire"))
383 return cmd_reflog_expire(argc - 1, argv + 1, prefix);
379 - else
380 - usage(reflog_usage);
384 +
385 + /* Not a recognized reflog command..*/
386 + usage(reflog_usage);
387 }
builtin.h
+1
@@ -40,6 +40,7 @@ extern int cmd_grep(int argc, const char **argv, const char *prefix);
40 extern int cmd_help(int argc, const char **argv, const char *prefix);
41 extern int cmd_init_db(int argc, const char **argv, const char *prefix);
42 extern int cmd_log(int argc, const char **argv, const char *prefix);
43 +extern int cmd_log_reflog(int argc, const char **argv, const char *prefix);
44 extern int cmd_ls_files(int argc, const char **argv, const char *prefix);
45 extern int cmd_ls_tree(int argc, const char **argv, const char *prefix);
46 extern int cmd_mailinfo(int argc, const char **argv, const char *prefix);