{"thread":{"id":"6446","subject":"[PATCH 3/3] show-branch --reflog: show the reflog message at the top.","startedAt":"2007-01-19T23:51:07Z","lastAt":"2007-01-20T09:39:39Z","messageCount":11,"participants":["Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"32104","messageId":"7virf2d190.fsf@assigned-by-dhcp.cox.net","threadId":"6446","inReplyTo":null,"subject":"[PATCH 3/3] show-branch --reflog: show the reflog message at the top.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-19T23:51:07Z","receivedAt":"2007-01-19T23:51:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This changes the output so the list at the top shows the reflog\nmessage, along with their relative timestamps.\n\nYou can use --reflog=<n> to show <n> most recent log entries, or\nuse --reflog=<n>,<b> to show <n> entries going back from the\nentry <b>.  <b> can be either a number (so --reflog=4,20 shows 4\nrecords starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').\n\nHere is a sample output (with --list option):\n\n  $ git show-branch --reflog=10 --list jc/show-reflog\n    [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref\n    [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^\n    [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho\n    [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho\n    [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a\n    [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a\n    [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a\n    [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi\n    [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4\n    [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use\n\nThis shows what I did more cleanly:\n\n  $ git show-branch --reflog=10 jc/show-reflog\n  ! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref\n   ! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^\n    ! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:\n     ! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:\n      ! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_\n       ! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read\n        ! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea\n         ! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow\n          ! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4\n           ! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r\n  ----------\n  +          [jc/show-reflog@{0}] show-branch --reflog: show the reflog\n    +        [jc/show-reflog@{2}] show-branch --reflog: show the reflog\n   +++       [jc/show-reflog@{1}] show-branch --reflog: show the reflog\n  +++++      [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro\n       +     [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro\n        +    [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro\n         +   [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r\n           + [jc/show-reflog@{9}] show-branch --reflog: use updated rea\n           + [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c\n           + [jc/show-reflog@{9}~2] show-branch --reflog: show the refl\n           + [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the\n  ++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM\n\nAt @{9}, I had a commit to complete 5 patch series, but I wanted\nto consolidate two commits that enhances read_ref_at() into one\n(they were @{9}^ and @{9}~3), and another two that touch show-branch\ninto one (@{9} and @{9}~2).\n\nI first saved them with \"format-patch -4\", and then did a reset\nat @{8}.  At @{7}, I applied one of them with \"am\", and then\nused \"git-apply\" on the other one, and amended the commit at\n@{6} (so @{6} and @{7} has the same parent).  I did not like the\nlog message, so I amended again at @{5}.\n\nThen I cherry-picked @{9}~2 to create @{3} (the log message\nshows that it needs to learn to set GIT_REFLOG_ACTION -- it uses\n\"git-commit\" and the log entry is attributed for it).  Another\ncherry-pick built @{2} out of @{9}, but what I wanted to do was\nto squash these two into one, so I did a \"reset HEAD^\" at @{1}\nand then made the final commit by amending what was at the top.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n Documentation/git-show-branch.txt |   15 ++++-\n builtin-show-branch.c             |  122 ++++++++++++++++++++++++++++--------\n refs.c                            |    5 +-\n 3 files changed, 109 insertions(+), 33 deletions(-)\n\ndiff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt\nindex 912e15b..529f3a6 100644\n--- a/Documentation/git-show-branch.txt\n+++ b/Documentation/git-show-branch.txt\n@@ -11,7 +11,7 @@ SYNOPSIS\n 'git-show-branch' [--all] [--remotes] [--topo-order] [--current]\n \t\t[--more=<n> | --list | --independent | --merge-base]\n \t\t[--no-name | --sha1-name] [--topics] [<rev> | <glob>]...\n-'git-show-branch' --reflog[=<n>] <ref>\n+'git-show-branch' --reflog[=<n>[,<base>]] [--list] <ref>\n \n DESCRIPTION\n -----------\n@@ -97,8 +97,10 @@ OPTIONS\n \twill show the revisions given by \"git rev-list {caret}master\n \ttopic1 topic2\"\n \n---reflog[=<n>] <ref>::\n-\tShows <n> most recent ref-log entries for the given ref.\n+--reflog[=<n>[,<base>]] <ref>::\n+\tShows <n> most recent ref-log entries for the given\n+\tref.  If <base> is given, <n> entries going back from\n+\tthat entry.  <base> can be specified as count or date\n \n \n Note that --more, --list, --independent and --merge-base options\n@@ -165,6 +167,13 @@ With this, `git show-branch` without extra parameters would show\n only the primary branches.  In addition, if you happen to be on\n your topic branch, it is shown as well.\n \n+------------\n+$ git show-branch --reflog='10,1 hour ago' --list master\n+------------\n+\n+shows 10 reflog entries going back from the tip as of 1 hour ago.\n+Without `--list`, the output also shows how these tips are\n+topologically related with each other.\n \n \n Author\ndiff --git a/builtin-show-branch.c b/builtin-show-branch.c\nindex c67f2fa..452c15f 100644\n--- a/builtin-show-branch.c\n+++ b/builtin-show-branch.c\n@@ -346,18 +346,21 @@ static void sort_ref_range(int bottom, int top)\n \t      compare_ref_name);\n }\n \n-static int append_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)\n+static int append_ref(const char *refname, const unsigned char *sha1,\n+\t\t      int allow_dups)\n {\n \tstruct commit *commit = lookup_commit_reference_gently(sha1, 1);\n \tint i;\n \n \tif (!commit)\n \t\treturn 0;\n-\t/* Avoid adding the same thing twice */\n-\tfor (i = 0; i < ref_name_cnt; i++)\n-\t\tif (!strcmp(refname, ref_name[i]))\n-\t\t\treturn 0;\n \n+\tif (!allow_dups) {\n+\t\t/* Avoid adding the same thing twice */\n+\t\tfor (i = 0; i < ref_name_cnt; i++)\n+\t\t\tif (!strcmp(refname, ref_name[i]))\n+\t\t\t\treturn 0;\n+\t}\n \tif (MAX_REVS <= ref_name_cnt) {\n \t\tfprintf(stderr, \"warning: ignoring %s; \"\n \t\t\t\"cannot handle more than %d refs\\n\",\n@@ -380,7 +383,7 @@ static int append_head_ref(const char *refname, const unsigned char *sha1, int f\n \t */\n \tif (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1))\n \t\tofs = 5;\n-\treturn append_ref(refname + ofs, sha1, flag, cb_data);\n+\treturn append_ref(refname + ofs, sha1, 0);\n }\n \n static int append_remote_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)\n@@ -394,14 +397,14 @@ static int append_remote_ref(const char *refname, const unsigned char *sha1, int\n \t */\n \tif (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1))\n \t\tofs = 5;\n-\treturn append_ref(refname + ofs, sha1, flag, cb_data);\n+\treturn append_ref(refname + ofs, sha1, 0);\n }\n \n static int append_tag_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)\n {\n \tif (strncmp(refname, \"refs/tags/\", 10))\n \t\treturn 0;\n-\treturn append_ref(refname + 5, sha1, flag, cb_data);\n+\treturn append_ref(refname + 5, sha1, 0);\n }\n \n static const char *match_ref_pattern = NULL;\n@@ -434,7 +437,7 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i\n \t\treturn append_head_ref(refname, sha1, flag, cb_data);\n \tif (!strncmp(\"refs/tags/\", refname, 10))\n \t\treturn append_tag_ref(refname, sha1, flag, cb_data);\n-\treturn append_ref(refname, sha1, flag, cb_data);\n+\treturn append_ref(refname, sha1, 0);\n }\n \n static void snarf_refs(int head, int remotes)\n@@ -507,7 +510,7 @@ static void append_one_rev(const char *av)\n {\n \tunsigned char revkey[20];\n \tif (!get_sha1(av, revkey)) {\n-\t\tappend_ref(av, revkey, 0, NULL);\n+\t\tappend_ref(av, revkey, 0);\n \t\treturn;\n \t}\n \tif (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) {\n@@ -562,9 +565,24 @@ static int omit_in_dense(struct commit *commit, struct commit **rev, int n)\n \treturn 0;\n }\n \n+static void parse_reflog_param(const char *arg, int *cnt, const char **base)\n+{\n+\tchar *ep;\n+\t*cnt = strtoul(arg, &ep, 10);\n+\tif (*ep == ',')\n+\t\t*base = ep + 1;\n+\telse if (*ep)\n+\t\tdie(\"unrecognized reflog param '%s'\", arg + 9);\n+\telse\n+\t\t*base = NULL;\n+\tif (*cnt <= 0)\n+\t\t*cnt = DEFAULT_REFLOG;\n+}\n+\n int cmd_show_branch(int ac, const char **av, const char *prefix)\n {\n \tstruct commit *rev[MAX_REVS], *commit;\n+\tchar *reflog_msg[MAX_REVS];\n \tstruct commit_list *list = NULL, *seen = NULL;\n \tunsigned int rev_mask[MAX_REVS];\n \tint num_rev, i, extra = 0;\n@@ -585,6 +603,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \tint topics = 0;\n \tint dense = 1;\n \tint reflog = 0;\n+\tconst char *reflog_base = NULL;\n \n \tgit_config(git_show_branch_config);\n \n@@ -631,21 +650,27 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\telse if (!strcmp(arg, \"--reflog\")) {\n \t\t\treflog = DEFAULT_REFLOG;\n \t\t}\n-\t\telse if (!strncmp(arg, \"--reflog=\", 9)) {\n-\t\t\tchar *end;\n-\t\t\treflog = strtoul(arg + 9, &end, 10);\n-\t\t\tif (*end != '\\0')\n-\t\t\t\tdie(\"unrecognized reflog count '%s'\", arg + 9);\n-\t\t}\n+\t\telse if (!strncmp(arg, \"--reflog=\", 9))\n+\t\t\tparse_reflog_param(arg + 9, &reflog, &reflog_base);\n \t\telse\n \t\t\tusage(show_branch_usage);\n \t\tac--; av++;\n \t}\n \tac--; av++;\n \n-\t/* Only one of these is allowed */\n-\tif (1 < independent + merge_base + (extra != 0) + (!!reflog))\n-\t\tusage(show_branch_usage);\n+\tif (!!extra || !!reflog) {\n+\t\t/* \"listing\" mode is incompatible with\n+\t\t * independent nor merge-base modes.\n+\t\t */\n+\t\tif (independent || merge_base)\n+\t\t\tusage(show_branch_usage);\n+\t\tif (!!reflog && (0 < extra))\n+\t\t\t/*\n+\t\t\t * Asking for --more in reflog mode does not\n+\t\t\t * make sense.\n+\t\t\t */\n+\t\t\tusage(show_branch_usage);\n+\t}\n \n \t/* If nothing is specified, show all branches by default */\n \tif (ac + all_heads + all_remotes == 0)\n@@ -654,14 +679,51 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \tif (all_heads + all_remotes)\n \t\tsnarf_refs(all_heads, all_remotes);\n \tif (reflog) {\n-\t\tint reflen;\n-\t\tif (!ac)\n+\t\tunsigned char sha1[20];\n+\t\tchar nth_desc[256];\n+\t\tchar *ref;\n+\t\tint base = 0;\n+\t\tif (ac != 1)\n \t\t\tdie(\"--reflog option needs one branch name\");\n-\t\treflen = strlen(*av);\n+\t\tif (!dwim_ref(*av, strlen(*av), sha1, &ref))\n+\t\t\tdie(\"No such ref %s\", *av);\n+\n+\t\t/* Has the base been specified? */\n+\t\tif (reflog_base) {\n+\t\t\tchar *ep;\n+\t\t\tbase = strtoul(reflog_base, &ep, 10);\n+\t\t\tif (*ep) {\n+\t\t\t\t/* Ah, that is a date spec... */\n+\t\t\t\tunsigned long at;\n+\t\t\t\tat = approxidate(reflog_base);\n+\t\t\t\tread_ref_at(ref, at, -1, sha1, NULL,\n+\t\t\t\t\t    NULL, NULL, &base);\n+\t\t\t}\n+\t\t}\n+\n \t\tfor (i = 0; i < reflog; i++) {\n-\t\t\tchar *name = xmalloc(reflen + 20);\n-\t\t\tsprintf(name, \"%s@{%d}\", *av, i);\n-\t\t\tappend_one_rev(name);\n+\t\t\tchar *logmsg, *msg, *m;\n+\t\t\tunsigned long timestamp;\n+\t\t\tint tz;\n+\n+\t\t\tif (read_ref_at(ref, 0, base+i, sha1, &logmsg,\n+\t\t\t\t\t&timestamp, &tz, NULL)) {\n+\t\t\t\treflog = i;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tmsg = strchr(logmsg, '\\t');\n+\t\t\tif (!msg)\n+\t\t\t\tmsg = \"(none)\";\n+\t\t\telse\n+\t\t\t\tmsg++;\n+\t\t\tm = xmalloc(strlen(msg) + 200);\n+\t\t\tsprintf(m, \"(%s) %s\",\n+\t\t\t\tshow_date(timestamp, 0, 1),\n+\t\t\t\tmsg);\n+\t\t\treflog_msg[i] = m;\n+\t\t\tfree(logmsg);\n+\t\t\tsprintf(nth_desc, \"%s@{%d}\", *av, base+i);\n+\t\t\tappend_ref(nth_desc, sha1, 1);\n \t\t}\n \t}\n \telse {\n@@ -760,8 +822,14 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\t\tprintf(\"%c [%s] \",\n \t\t\t\t       is_head ? '*' : '!', ref_name[i]);\n \t\t\t}\n-\t\t\t/* header lines never need name */\n-\t\t\tshow_one_commit(rev[i], 1);\n+\n+\t\t\tif (!reflog) {\n+\t\t\t\t/* header lines never need name */\n+\t\t\t\tshow_one_commit(rev[i], 1);\n+\t\t\t}\n+\t\t\telse\n+\t\t\t\tputs(reflog_msg[i]);\n+\n \t\t\tif (is_head)\n \t\t\t\thead_at = i;\n \t\t}\ndiff --git a/refs.c b/refs.c\nindex 60375a7..8117328 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1068,6 +1068,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *\n \t\t\tdie(\"Log %s is corrupt.\", logfile);\n \t\tdate = strtoul(lastgt + 1, &tz_c, 10);\n \t\tif (date <= at_time || cnt == 0) {\n+\t\t\ttz = strtoul(tz_c, NULL, 10);\n \t\t\tif (msg)\n \t\t\t\t*msg = ref_msg(rec, logend);\n \t\t\tif (cutoff_time)\n@@ -1075,14 +1076,13 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *\n \t\t\tif (cutoff_tz)\n \t\t\t\t*cutoff_tz = tz;\n \t\t\tif (cutoff_cnt)\n-\t\t\t\t*cutoff_cnt = reccnt;\n+\t\t\t\t*cutoff_cnt = reccnt - 1;\n \t\t\tif (lastrec) {\n \t\t\t\tif (get_sha1_hex(lastrec, logged_sha1))\n \t\t\t\t\tdie(\"Log %s is corrupt.\", logfile);\n \t\t\t\tif (get_sha1_hex(rec + 41, sha1))\n \t\t\t\t\tdie(\"Log %s is corrupt.\", logfile);\n \t\t\t\tif (hashcmp(logged_sha1, sha1)) {\n-\t\t\t\t\ttz = strtoul(tz_c, NULL, 10);\n \t\t\t\t\tfprintf(stderr,\n \t\t\t\t\t\t\"warning: Log %s has gap after %s.\\n\",\n \t\t\t\t\t\tlogfile, show_rfc2822_date(date, tz));\n@@ -1096,7 +1096,6 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *\n \t\t\t\tif (get_sha1_hex(rec + 41, logged_sha1))\n \t\t\t\t\tdie(\"Log %s is corrupt.\", logfile);\n \t\t\t\tif (hashcmp(logged_sha1, sha1)) {\n-\t\t\t\t\ttz = strtoul(tz_c, NULL, 10);\n \t\t\t\t\tfprintf(stderr,\n \t\t\t\t\t\t\"warning: Log %s unexpectedly ended on %s.\\n\",\n \t\t\t\t\t\tlogfile, show_rfc2822_date(date, tz));\n-- \n1.5.0.rc1.gcb48c\n"},{"id":"32108","messageId":"Pine.LNX.4.63.0701200116280.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6446","inReplyTo":"7virf2d190.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 3/3] show-branch --reflog: show the reflog message at the top.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-20T00:16:51Z","receivedAt":"2007-01-20T00:16:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\ndoes this mean you did not get used to \"--walk-reflogs\"? Just wanna know.\n\nCiao,\nDscho\n"},{"id":"32110","messageId":"7v4pqmczqa.fsf@assigned-by-dhcp.cox.net","threadId":"6446","inReplyTo":"Pine.LNX.4.63.0701200116280.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 3/3] show-branch --reflog: show the reflog message at the top.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-20T00:23:57Z","receivedAt":"2007-01-20T00:23:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> does this mean you did not get used to \"--walk-reflogs\"? Just wanna know.\n\nThat's independent.\n\nI still am having a hard time trying to explain what these\ncommands would do, and why they might be useful:\n\n\tgit-log --walk-reflogs master..next\n\tgit-log --walk-reflogs master -- Documentation/\n\nOn the other hand I can understand why this might be useful:\n\n\tgit-log --walk-reflogs master\n"},{"id":"32114","messageId":"Pine.LNX.4.63.0701200135500.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6446","inReplyTo":"7v4pqmczqa.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 3/3] show-branch --reflog: show the reflog message at the top.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-20T00:42:31Z","receivedAt":"2007-01-20T00:42:31Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 19 Jan 2007, Junio C Hamano wrote:\n\n> I still am having a hard time trying to explain what these\n> commands would do, and why they might be useful:\n> \n> \tgit-log --walk-reflogs master..next\n\nI had less problems explaining that when walking fell back to walking the \nparents.\n\nIt could even make sense to walk reflogs instead of parents _only_ for \ninteresting commits (i.e. \"next\" in your example, but not \"master\"), so \nthat you can ask for commits made to a certain in your local repository, \nwhich are not (yet) in some other branch.\n\nWhich would include commits which were ammended (and thus are no longer \nin the ancestry of the branch).\n\nOf course, you could always say: if you ask for strange things, you will \nget strange things.\n\n> \tgit-log --walk-reflogs master -- Documentation/\n\nAh, but that is way easier!\n\nFor example: I _know_ that something worked some time ago, and it was \nprobably in git.c. So ask \"git-log --walk-reflogs -- git.c\", and you will \nsoon find out where to start bisecting.\n\n> On the other hand I can understand why this might be useful:\n> \n> \tgit-log --walk-reflogs master\n\nI like it already. But of course, I also like your patch saying \"3 days \nago\" instead of a date.\n\nCiao,\nDscho\n"},{"id":"32116","messageId":"7vr6tqbjt8.fsf@assigned-by-dhcp.cox.net","threadId":"6446","inReplyTo":"Pine.LNX.4.63.0701200135500.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 3/3] show-branch --reflog: show the reflog message at the top.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-20T00:53:07Z","receivedAt":"2007-01-20T00:53:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Fri, 19 Jan 2007, Junio C Hamano wrote:\n>\n>> I still am having a hard time trying to explain what these\n>> commands would do, and why they might be useful:\n>> \n>> \tgit-log --walk-reflogs master..next\n>\n> I had less problems explaining that when walking fell back to walking the \n> parents.\n>\n> It could even make sense to...\n\n(meaning that is not what the code does...)\n\n> Of course, you could always say: if you ask for strange things, you will \n> get strange things.\n\nBut if you have to say that, doesn't it suggest that accepting\nthe option --walk-reflogs when you have anything other than one\nsingle positive commit in revs.pending leads to end user\nconfusion?\n\nThat's what I was after.  The theme is the same about my\nhesitation against --reverse.\n\nOn the other hand,\n\n>> \tgit-log --walk-reflogs master -- Documentation/\n>\n> Ah, but that is way easier!\n>\n> For example: I _know_ that something worked some time ago, and it was \n> probably in git.c. So ask \"git-log --walk-reflogs -- git.c\", and you will \n> soon find out where to start bisecting.\n\nthere is no reason to forbid pathspec when --walk-reflogs is in\neffect, which I agree.\n"},{"id":"32122","messageId":"Pine.LNX.4.63.0701200218290.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6446","inReplyTo":"7vr6tqbjt8.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 3/3] show-branch --reflog: show the reflog message at the top.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-20T01:19:43Z","receivedAt":"2007-01-20T01:19:43Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 19 Jan 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > On Fri, 19 Jan 2007, Junio C Hamano wrote:\n> >\n> >> I still am having a hard time trying to explain what these\n> >> commands would do, and why they might be useful:\n> >> \n> >> \tgit-log --walk-reflogs master..next\n> >\n> > I had less problems explaining that when walking fell back to walking the \n> > parents.\n> >\n> > It could even make sense to...\n> \n> (meaning that is not what the code does...)\n> \n> > Of course, you could always say: if you ask for strange things, you will \n> > get strange things.\n> \n> But if you have to say that, doesn't it suggest that accepting\n> the option --walk-reflogs when you have anything other than one\n> single positive commit in revs.pending leads to end user\n> confusion?\n\nHow about failing if there are _uninteresting_ commits? So,\n\n\tgit log --walk-reflogs next master\n\nstill works?\n\nCiao,\nDscho\n"},{"id":"32127","messageId":"7v4pqmbhzg.fsf@assigned-by-dhcp.cox.net","threadId":"6446","inReplyTo":"Pine.LNX.4.63.0701200218290.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 3/3] show-branch --reflog: show the reflog message at the top.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-20T01:32:35Z","receivedAt":"2007-01-20T01:32:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> How about failing if there are _uninteresting_ commits? So,\n>\n> \tgit log --walk-reflogs next master\n>\n> still works?\n\nThat feels like a good way to deal with it.  I think people may\nalso appreciate timestamps on Reflog headers you add to the\noutput.\n\nThat change makes\n\n\t$ git log --walk-reflogs master..next\n        fatal: No reflogs found for 'master..next'\n\na non issue, for one thing.\n\nUnfortunately,\n\n\t$ git log --walk-reflogs ^master next \n\nis not something I can read and make heads or tails of it.  So\nI'll try something smaller:\n\n\t$ git log --walk-reflogs ^master jc/show-reflog\n\nshows only three commits (the same as without --walk-reflogs),\nalthough I have tons of rewinds and rebases.  There is something\nbroken, or perhaps the semantics of --walk-reflogs does not\nmatch what humans would expect when interacting with revision\nlimiting.  This would also become an non-issue if we do not\nallow negative ones.\n"},{"id":"32135","messageId":"Pine.LNX.4.63.0701200325380.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6446","inReplyTo":"7v4pqmbhzg.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] --walk-reflogs: disallow uninteresting commits","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-20T02:28:19Z","receivedAt":"2007-01-20T02:28:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nDo not allow uninteresting commits with --walk-reflogs, since it is\nnot clear what should be shown in these cases:\n\n\t$ git log --walk-reflogs master..next\n\t$ git log --walk-reflogs ^master\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\n\tOn Fri, 19 Jan 2007, Junio C Hamano wrote:\n\t\n\t> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\t> \n\t> > How about failing if there are _uninteresting_ commits? So,\n\t> >\n\t> > \tgit log --walk-reflogs next master\n\t> >\n\t> > still works?\n\t> \n\t> That feels like a good way to deal with it.\n\n\tHere you are.\n\n\t> I think people may also appreciate timestamps on Reflog headers \n\t> you add to the output.\n\n\tAt the moment, if you ask for @{1} (or leave it out), you will see \n\tthem enumerated by number. If you ask for @{now}, you will see \n\tthem identified by date...\n\n reflog-walk.c |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex d4b49c7..2d97411 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -145,6 +145,9 @@ void add_reflog_for_walk(struct reflog_walk_info *info,\n \tchar *branch, *at = strchr(name, '@');\n \tstruct commit_reflog *commit_reflog;\n \n+\tif (commit->object.flags & UNINTERESTING)\n+\t\tdie (\"Cannot walk reflogs for %s\", name);\n+\n \tbranch = xstrdup(name);\n \tif (at && at[1] == '{') {\n \t\tchar *ep;\n-- \n1.5.0.rc1.g5a400-dirty\n"},{"id":"32140","messageId":"7v64b29naa.fsf@assigned-by-dhcp.cox.net","threadId":"6446","inReplyTo":"Pine.LNX.4.63.0701200325380.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] --walk-reflogs: disallow uninteresting commits","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-20T07:21:01Z","receivedAt":"2007-01-20T07:21:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> \t> I think people may also appreciate timestamps on Reflog headers \n> \t> you add to the output.\n>\n> \tAt the moment, if you ask for @{1} (or leave it out), you will see \n> \tthem enumerated by number. If you ask for @{now}, you will see \n> \tthem identified by date...\n\nThanks.  This certainly needs a better documentation -- the attached is\nmy try.\n\nBy the way, I haven't looked into it, but does this ring a bell?\n\n    $ git-log --walk-reflogs -1 --pretty=s master@{1.day}\n    commit 72fe6a59890870ed9c3e9e1e6381fc0d7ba75fe4\n    Reflog: master@{Thu, 1 Jan 1970 00:00:00 +0000} ((null))\n    Reflog message: (null)Author: Junio C Hamano <junkio@cox.net>\n\n        Documentation: Generate command lists.\n\n\n---\n\ndiff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt\nindex 86c94e7..fcc540b 100644\n--- a/Documentation/git-rev-list.txt\n+++ b/Documentation/git-rev-list.txt\n@@ -190,6 +190,21 @@ limiting may be applied.\n \tIn addition to the '<commit>' listed on the command\n \tline, read them from the standard input.\n \n+--walk-reflogs::\n+\n+\tInstead of walking the commit ancestry chain, walk\n+\treflog entries from the most recent one to older ones.\n+\tWhen this option is used you cannot specify commits to\n+\texclude (that is, '{caret}commit', 'commit1..commit2',\n+\tnor 'commit1...commit2' notations cannot be used).\n++\n+With '\\--pretty' format other than oneline (for obvious reasons),\n+this causes the output to have two extra lines of information\n+taken from the reflog.  By default, 'commit@{Nth}' notation is\n+used in the output.  When the starting commit is specified as\n+'commit@{now}', output also uses 'commit@{timestamp}' notation\n+instead.\n+\n --merge::\n \n \tAfter a failed merge, show refs that touch files having a\n"},{"id":"32143","messageId":"Pine.LNX.4.63.0701201029400.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6446","inReplyTo":"7v64b29naa.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] --walk-reflogs: disallow uninteresting commits","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-20T09:32:16Z","receivedAt":"2007-01-20T09:32:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 19 Jan 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > \t> I think people may also appreciate timestamps on Reflog headers \n> > \t> you add to the output.\n> >\n> > \tAt the moment, if you ask for @{1} (or leave it out), you will see \n> > \tthem enumerated by number. If you ask for @{now}, you will see \n> > \tthem identified by date...\n> \n> Thanks.  This certainly needs a better documentation -- the attached is\n> my try.\n\n;-)\n\nI sort of waited for comments on this behaviour. Maybe it would be better \nto always show the number, _and_ a relative time? I.e.\n\n\tReflog @{2}: master@{17.5 minutes ago} (message)\n\n> By the way, I haven't looked into it, but does this ring a bell?\n> \n>     $ git-log --walk-reflogs -1 --pretty=s master@{1.day}\n>     commit 72fe6a59890870ed9c3e9e1e6381fc0d7ba75fe4\n>     Reflog: master@{Thu, 1 Jan 1970 00:00:00 +0000} ((null))\n>     Reflog message: (null)Author: Junio C Hamano <junkio@cox.net>\n> \n>         Documentation: Generate command lists.\n\nNot yet. Will look into it.\n\nCiao,\nDscho\n"},{"id":"32144","messageId":"7vr6tq82as.fsf@assigned-by-dhcp.cox.net","threadId":"6446","inReplyTo":"Pine.LNX.4.63.0701201029400.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] --walk-reflogs: disallow uninteresting commits","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-20T09:39:39Z","receivedAt":"2007-01-20T09:39:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Here is what I have at the top of the topic (after a few fixups,\nso it might not apply directly).\n\n-- >8 --\n[PATCH] Fix --walk-reflog with --pretty=oneline\n\nNow, \"git log --abbrev-commit --pretty=o --walk-reflogs HEAD\" is\nreasonably pleasant to use.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n Documentation/git-rev-list.txt |    4 +++-\n log-tree.c                     |    3 ++-\n reflog-walk.c                  |   33 ++++++++++++++++++++++-----------\n reflog-walk.h                  |    2 +-\n 4 files changed, 28 insertions(+), 14 deletions(-)\n\ndiff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt\nindex fcc540b..a996f6c 100644\n--- a/Documentation/git-rev-list.txt\n+++ b/Documentation/git-rev-list.txt\n@@ -27,6 +27,7 @@ SYNOPSIS\n \t     [ \\--pretty | \\--header ]\n \t     [ \\--bisect ]\n \t     [ \\--merge ]\n+\t     [ \\--walk-reflogs ]\n \t     <commit>... [ \\-- <paths>... ]\n \n DESCRIPTION\n@@ -203,7 +204,8 @@ this causes the output to have two extra lines of information\n taken from the reflog.  By default, 'commit@{Nth}' notation is\n used in the output.  When the starting commit is specified as\n 'commit@{now}', output also uses 'commit@{timestamp}' notation\n-instead.\n+instead.  Under '\\--pretty=oneline', the commit message is\n+prefixed with this information on the same line.\n \n --merge::\n \ndiff --git a/log-tree.c b/log-tree.c\nindex f043ad3..c0fa096 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -225,7 +225,8 @@ void show_log(struct rev_info *opt, const char *sep)\n \t\t       diff_get_color(opt->diffopt.color_diff, DIFF_RESET));\n \t\tputchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\\n');\n \t\tif (opt->reflog_info)\n-\t\t\tshow_reflog_message(opt->reflog_info);\n+\t\t\tshow_reflog_message(opt->reflog_info,\n+\t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE);;\n \t}\n \n \t/*\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 989a7ae..8ccbe97 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -219,21 +219,32 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)\n \tcommit->object.flags &= ~(ADDED | SEEN | SHOWN);\n }\n \n-void show_reflog_message(struct reflog_walk_info* info)\n+void show_reflog_message(struct reflog_walk_info* info, int oneline)\n {\n \tif (info && info->last_commit_reflog) {\n \t\tstruct commit_reflog *commit_reflog = info->last_commit_reflog;\n \t\tstruct reflog_info *info;\n \n-\t\tprintf(\"Reflog: %s@{\", commit_reflog->reflogs->ref);\n-\t\tinfo = &commit_reflog->reflogs->items[commit_reflog->recno + 1];\n-\t\tif (commit_reflog->flag)\n-\t\t\tprintf(\"%s\", show_rfc2822_date(info->timestamp,\n-\t\t\t\t\t\tinfo->tz));\n-\t\telse\n-\t\t\tprintf(\"%d\", commit_reflog->reflogs->nr\n-\t\t\t\t\t- 2 - commit_reflog->recno);\n-\t\tprintf(\"} (%s)\\nReflog message: %s\",\n-\t\t\tinfo->email, info->message);\n+\t\tinfo = &commit_reflog->reflogs->items[commit_reflog->recno+1];\n+\t\tif (oneline) {\n+\t\t\tprintf(\"%s@{\", commit_reflog->reflogs->ref);\n+\t\t\tif (commit_reflog->flag)\n+\t\t\t\tprintf(\"%s\", show_date(info->timestamp, 0, 1));\n+\t\t\telse\n+\t\t\t\tprintf(\"%d\", commit_reflog->reflogs->nr\n+\t\t\t\t       - 2 - commit_reflog->recno);\n+\t\t\tprintf(\"}: \");\n+\t\t}\n+\t\telse {\n+\t\t\tprintf(\"Reflog: %s@{\", commit_reflog->reflogs->ref);\n+\t\t\tif (commit_reflog->flag)\n+\t\t\t\tprintf(\"%s\", show_rfc2822_date(info->timestamp,\n+\t\t\t\t\t\t\t       info->tz));\n+\t\t\telse\n+\t\t\t\tprintf(\"%d\", commit_reflog->reflogs->nr\n+\t\t\t\t       - 2 - commit_reflog->recno);\n+\t\t\tprintf(\"} (%s)\\nReflog message: %s\",\n+\t\t\t       info->email, info->message);\n+\t\t}\n \t}\n }\ndiff --git a/reflog-walk.h b/reflog-walk.h\nindex 787996b..e63d867 100644\n--- a/reflog-walk.h\n+++ b/reflog-walk.h\n@@ -6,6 +6,6 @@ extern void add_reflog_for_walk(struct reflog_walk_info *info,\n \t\tstruct commit *commit, const char *name);\n extern void fake_reflog_parent(struct reflog_walk_info *info,\n \t\tstruct commit *commit);\n-extern void show_reflog_message(struct reflog_walk_info* info);\n+extern void show_reflog_message(struct reflog_walk_info *info, int);\n \n #endif\n-- \n1.5.0.rc1.g33dd1\n"}]}