{"thread":{"id":"21218","subject":"[RFC PATCH 1/5] reflog-walk: refactor the branch@{num} formatting","startedAt":"2009-10-12T21:06:02Z","lastAt":"2009-10-14T09:58:34Z","messageCount":14,"participants":["Thomas Rast","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"124750","messageId":"cover.1255380039.git.trast@student.ethz.ch","threadId":"21218","inReplyTo":"20091012175201.GA10263@coredump.intra.peff.net","subject":"[RFC PATCH 0/5] Pretty formats for reflog data","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-12T21:06:02Z","receivedAt":"2009-10-12T21:06:02Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"[I forgot to address the list on the first batch, sorry for the spam.]\n\nJeff King wrote:\n> On Mon, Oct 12, 2009 at 05:47:34PM +0200, Jef Driesen wrote:\n> \n> > Is it possible to make \"git stash list\" show more than 10 items?\n> \n> Try \"git stash list -30\".\n> \n> Stash listing is internally just \"git log -g refs/stash\", so you can\n> pass any formatting or limiting arguments you want there (see the git\n> log documentation for ideas). If no arguments are given, we pass \"-10\".\n\nThis seems fairly arbitrary, doesn't it?  My own working theory is\nthat Nanako put it in because the git-log|sed construct inherently\nbars any way to a pager, so it needs to be cut short.\n\nSo suppose we could somehow get rid of the |sed... like if we had\n--pretty specifiers for the reflog information.\n\nSadly\n\n  git log -g --format=\"%h %g: %G\"\n\nstill fails to exactly replicate the reflog format: if the reflog was\ncut off during garbage collection, the last entry refers to a no\nlonger existing commit causing a stray ':' on that line.  Oh, well.\n\nIt's also still RFC because:\n\n* I don't like the massive code churn in 2/5, maybe someone sees a\n  better option.\n\n* 5/5 has a pretty lame excuse.  I could also just change it in 'git\n  stash list' to limit the backwards-incompatibility damage, but\n  that's also a maintenance headache.\n\n\nThomas Rast (5):\n  reflog-walk: refactor the branch@{num} formatting\n  Introduce new pretty formats %g and %G for reflog information\n  stash: Use new %g/%G formats instead of sed\n  stash list: drop the default limit of 10 stashes\n  stash: change built-in ref to 'stash' instead of 'refs/stash'\n\n archive.c             |    2 +-\n builtin-branch.c      |    3 +-\n builtin-checkout.c    |    2 +-\n builtin-commit.c      |    4 +-\n builtin-log.c         |    2 +-\n builtin-merge.c       |    2 +-\n builtin-rev-list.c    |    2 +-\n builtin-shortlog.c    |    2 +-\n builtin-show-branch.c |    2 +-\n commit.h              |    7 +++-\n git-stash.sh          |   10 +-----\n log-tree.c            |    4 +-\n pretty.c              |   20 +++++++++++--\n reflog-walk.c         |   72 ++++++++++++++++++++++++++++++++++---------------\n reflog-walk.h         |    7 +++++\n 15 files changed, 94 insertions(+), 47 deletions(-)\n"},{"id":"124748","messageId":"1c524798bde29912429d400f0c48591acadad6d7.1255380039.git.trast@student.ethz.ch","threadId":"21218","inReplyTo":"cover.1255380039.git.trast@student.ethz.ch","subject":"[RFC PATCH 1/5] reflog-walk: refactor the branch@{num} formatting","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-12T21:06:03Z","receivedAt":"2009-10-12T21:06:03Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"We'll use the same output in an upcoming commit, so refactor its\nformatting (which was duplicated anyway) into a separate function.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n reflog-walk.c |   56 ++++++++++++++++++++++++++++++++++----------------------\n 1 files changed, 34 insertions(+), 22 deletions(-)\n\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 5623ea6..9478dbc 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -241,36 +241,48 @@ 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, int oneline,\n+void get_reflog_selector(struct strbuf *sb,\n+\t\t\t struct reflog_walk_info *reflog_info,\n+\t\t\t enum date_mode dmode)\n+{\n+\tstruct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;\n+\tstruct reflog_info *info;\n+\n+\tif (!commit_reflog)\n+\t\treturn;\n+\n+\tstrbuf_addf(sb, \"%s@{\", commit_reflog->reflogs->ref);\n+\tif (commit_reflog->flag || dmode) {\n+\t\tinfo = &commit_reflog->reflogs->items[commit_reflog->recno+1];\n+\t\tstrbuf_addf(sb, \"%s\", show_date(info->timestamp,\n+\t\t\t\t\t\tinfo->tz,\n+\t\t\t\t\t\tdmode));\n+\t} else {\n+\t\tstrbuf_addf(sb, \"%d\", commit_reflog->reflogs->nr\n+\t\t\t    - 2 - commit_reflog->recno);\n+\t}\n+\n+\tstrbuf_addch(sb, '}');\n+}\n+\n+void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,\n \tenum date_mode dmode)\n {\n-\tif (info && info->last_commit_reflog) {\n-\t\tstruct commit_reflog *commit_reflog = info->last_commit_reflog;\n+\tif (reflog_info && reflog_info->last_commit_reflog) {\n+\t\tstruct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;\n \t\tstruct reflog_info *info;\n+\t\tstruct strbuf selector = STRBUF_INIT;\n \n \t\tinfo = &commit_reflog->reflogs->items[commit_reflog->recno+1];\n+\t\tget_reflog_selector(&selector, reflog_info, dmode);\n \t\tif (oneline) {\n-\t\t\tprintf(\"%s@{\", commit_reflog->reflogs->ref);\n-\t\t\tif (commit_reflog->flag || dmode)\n-\t\t\t\tprintf(\"%s\", show_date(info->timestamp,\n-\t\t\t\t\t\t       info->tz,\n-\t\t\t\t\t\t       dmode));\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\", info->message);\n+\t\t\tprintf(\"%s: %s\", selector.buf, info->message);\n \t\t}\n \t\telse {\n-\t\t\tprintf(\"Reflog: %s@{\", commit_reflog->reflogs->ref);\n-\t\t\tif (commit_reflog->flag || dmode)\n-\t\t\t\tprintf(\"%s\", show_date(info->timestamp,\n-\t\t\t\t\t\t\tinfo->tz,\n-\t\t\t\t\t\t\tdmode));\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\tprintf(\"Reflog: %s (%s)\\nReflog message: %s\",\n+\t\t\t       selector.buf, info->email, info->message);\n \t\t}\n+\n+\t\tstrbuf_release(&selector);\n \t}\n }\n-- \n1.6.5.64.g01287\n"},{"id":"124755","messageId":"e0321a8af8d702d24ace33510daff22d02f4e116.1255380039.git.trast@student.ethz.ch","threadId":"21218","inReplyTo":"cover.1255380039.git.trast@student.ethz.ch","subject":"[RFC PATCH 2/5] Introduce new pretty formats %g and %G for reflog information","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-12T21:06:04Z","receivedAt":"2009-10-12T21:06:04Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Add two new pretty escapes: %g expands to the reflog selector (i.e.,\nbranch@{number} or branch@{date}) and %G expands to the reflog\nmessage.\n\nWe use the newly refactored selector formatting function and introduce\nanother wrapper to get the reflog message.\n\nUnfortunately, we also need to pass down the reflog_walk_info from\nshow_log(), so this commit touches a lot of (unrelated) callers to\npretty_print_commit() and format_commit_message() to accomodate the\nextra argument.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n archive.c             |    2 +-\n builtin-branch.c      |    3 ++-\n builtin-checkout.c    |    2 +-\n builtin-commit.c      |    4 ++--\n builtin-log.c         |    2 +-\n builtin-merge.c       |    2 +-\n builtin-rev-list.c    |    2 +-\n builtin-shortlog.c    |    2 +-\n builtin-show-branch.c |    2 +-\n commit.h              |    7 +++++--\n log-tree.c            |    4 ++--\n pretty.c              |   20 +++++++++++++++++---\n reflog-walk.c         |   16 ++++++++++++++++\n reflog-walk.h         |    7 +++++++\n 14 files changed, 58 insertions(+), 17 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 0cc79d2..d325ce3 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -48,7 +48,7 @@ static void format_subst(const struct commit *commit,\n \t\tstrbuf_add(&fmt, b + 8, c - b - 8);\n \n \t\tstrbuf_add(buf, src, b - src);\n-\t\tformat_commit_message(commit, fmt.buf, buf, DATE_NORMAL);\n+\t\tformat_commit_message(commit, fmt.buf, buf, DATE_NORMAL, NULL);\n \t\tlen -= c + 1 - src;\n \t\tsrc  = c + 1;\n \t}\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 9f57992..d90bfaf 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -388,7 +388,8 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,\n \t\tcommit = item->commit;\n \t\tif (commit && !parse_commit(commit)) {\n \t\t\tpretty_print_commit(CMIT_FMT_ONELINE, commit,\n-\t\t\t\t\t    &subject, 0, NULL, NULL, 0, 0);\n+\t\t\t\t\t    &subject, 0, NULL, NULL, 0, 0,\n+\t\t\t\t\t    NULL);\n \t\t\tsub = subject.buf;\n \t\t}\n \ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex d050c37..b6b9c45 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -303,7 +303,7 @@ static void describe_detached_head(char *msg, struct commit *commit)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n \tparse_commit(commit);\n-\tpretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, 0, NULL, NULL, 0, 0);\n+\tpretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, 0, NULL, NULL, 0, 0, NULL);\n \tfprintf(stderr, \"%s %s... %s\\n\", msg,\n \t\tfind_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV), sb.buf);\n \tstrbuf_release(&sb);\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 200ffda..d63d467 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -685,7 +685,7 @@ static int message_is_empty(struct strbuf *sb)\n \tcommit = get_revision(&revs);\n \tif (commit) {\n \t\tstrbuf_release(&buf);\n-\t\tformat_commit_message(commit, \"%an <%ae>\", &buf, DATE_NORMAL);\n+\t\tformat_commit_message(commit, \"%an <%ae>\", &buf, DATE_NORMAL, NULL);\n \t\treturn strbuf_detach(&buf, NULL);\n \t}\n \tdie(\"No existing author found with '%s'\", name);\n@@ -943,7 +943,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \n \tif (!log_tree_commit(&rev, commit)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tformat_commit_message(commit, format + 7, &buf, DATE_NORMAL);\n+\t\tformat_commit_message(commit, format + 7, &buf, DATE_NORMAL, NULL);\n \t\tprintf(\"%s\\n\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 25e21ed..57df76e 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -1305,7 +1305,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \t\tif (verbose) {\n \t\t\tstruct strbuf buf = STRBUF_INIT;\n \t\t\tpretty_print_commit(CMIT_FMT_ONELINE, commit,\n-\t\t\t                    &buf, 0, NULL, NULL, 0, 0);\n+\t\t\t                    &buf, 0, NULL, NULL, 0, 0, NULL);\n \t\t\tprintf(\"%c %s %s\\n\", sign,\n \t\t\t       sha1_to_hex(commit->object.sha1), buf.buf);\n \t\t\tstrbuf_release(&buf);\ndiff --git a/builtin-merge.c b/builtin-merge.c\nindex b6b8428..70f1488 100644\n--- a/builtin-merge.c\n+++ b/builtin-merge.c\n@@ -291,7 +291,7 @@ static void squash_message(void)\n \t\tstrbuf_addf(&out, \"commit %s\\n\",\n \t\t\tsha1_to_hex(commit->object.sha1));\n \t\tpretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,\n-\t\t\tNULL, NULL, rev.date_mode, 0);\n+\t\t\tNULL, NULL, rev.date_mode, 0, NULL);\n \t}\n \tif (write(fd, out.buf, out.len) < 0)\n \t\tdie_errno(\"Writing SQUASH_MSG\");\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex 4ba1c12..78659c8 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -98,7 +98,7 @@ static void show_commit(struct commit *commit, void *data)\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tpretty_print_commit(revs->commit_format, commit,\n \t\t\t\t    &buf, revs->abbrev, NULL, NULL,\n-\t\t\t\t    revs->date_mode, 0);\n+\t\t\t\t    revs->date_mode, 0, NULL);\n \t\tif (revs->graph) {\n \t\t\tif (buf.len) {\n \t\t\t\tif (revs->commit_format != CMIT_FMT_ONELINE)\ndiff --git a/builtin-shortlog.c b/builtin-shortlog.c\nindex 4d4a3c8..128b382 100644\n--- a/builtin-shortlog.c\n+++ b/builtin-shortlog.c\n@@ -160,7 +160,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)\n \t\tstruct strbuf buf = STRBUF_INIT;\n \n \t\tpretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf,\n-\t\t\tDEFAULT_ABBREV, \"\", \"\", DATE_NORMAL, 0);\n+\t\t\tDEFAULT_ABBREV, \"\", \"\", DATE_NORMAL, 0, NULL);\n \t\tinsert_one_record(log, author, buf.buf);\n \t\tstrbuf_release(&buf);\n \t\treturn;\ndiff --git a/builtin-show-branch.c b/builtin-show-branch.c\nindex be95930..73ea7ce 100644\n--- a/builtin-show-branch.c\n+++ b/builtin-show-branch.c\n@@ -294,7 +294,7 @@ static void show_one_commit(struct commit *commit, int no_name)\n \n \tif (commit->object.parsed) {\n \t\tpretty_print_commit(CMIT_FMT_ONELINE, commit,\n-\t\t\t\t    &pretty, 0, NULL, NULL, 0, 0);\n+\t\t\t\t    &pretty, 0, NULL, NULL, 0, 0, NULL);\n \t\tpretty_str = pretty.buf;\n \t}\n \tif (!prefixcmp(pretty_str, \"[PATCH] \"))\ndiff --git a/commit.h b/commit.h\nindex f4fc5c5..93efeeb 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -69,14 +69,17 @@ enum cmit_fmt {\n extern char *reencode_commit_message(const struct commit *commit,\n \t\t\t\t     const char **encoding_p);\n extern void get_commit_format(const char *arg, struct rev_info *);\n+struct reflog_walk_info;\n extern void format_commit_message(const struct commit *commit,\n \t\t\t\t  const void *format, struct strbuf *sb,\n-\t\t\t\t  enum date_mode dmode);\n+\t\t\t\t  enum date_mode dmode,\n+\t\t\t\t  struct reflog_walk_info *reflog_info);\n extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*,\n                                 struct strbuf *,\n                                 int abbrev, const char *subject,\n                                 const char *after_subject, enum date_mode,\n-\t\t\t\tint need_8bit_cte);\n+\t\t\t\tint need_8bit_cte,\n+\t\t\t\tstruct reflog_walk_info *reflog_info);\n void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,\n \t\t   const char *line, enum date_mode dmode,\n \t\t   const char *encoding);\ndiff --git a/log-tree.c b/log-tree.c\nindex 1618f3c..e75f953 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -179,7 +179,7 @@ void get_patch_filename(struct commit *commit, int nr, const char *suffix,\n \tif (commit) {\n \t\tint max_len = start_len + FORMAT_PATCH_NAME_MAX - suffix_len;\n \n-\t\tformat_commit_message(commit, \"%f\", buf, DATE_NORMAL);\n+\t\tformat_commit_message(commit, \"%f\", buf, DATE_NORMAL, NULL);\n \t\tif (max_len < buf->len)\n \t\t\tstrbuf_setlen(buf, max_len);\n \t\tstrbuf_addstr(buf, suffix);\n@@ -408,7 +408,7 @@ void show_log(struct rev_info *opt)\n \t\tneed_8bit_cte = has_non_ascii(opt->add_signoff);\n \tpretty_print_commit(opt->commit_format, commit, &msgbuf,\n \t\t\t    abbrev, subject, extra_headers, opt->date_mode,\n-\t\t\t    need_8bit_cte);\n+\t\t\t    need_8bit_cte, opt->reflog_info);\n \n \tif (opt->add_signoff)\n \t\tappend_signoff(&msgbuf, opt->add_signoff);\ndiff --git a/pretty.c b/pretty.c\nindex f5983f8..0b67580 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -7,6 +7,7 @@\n #include \"mailmap.h\"\n #include \"log-tree.h\"\n #include \"color.h\"\n+#include \"reflog-walk.h\"\n \n static char *user_format;\n \n@@ -443,6 +444,7 @@ struct chunk {\n struct format_commit_context {\n \tconst struct commit *commit;\n \tenum date_mode dmode;\n+\tstruct reflog_walk_info *reflog_info;\n \tunsigned commit_header_parsed:1;\n \tunsigned commit_message_parsed:1;\n \n@@ -701,6 +703,14 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,\n \tcase 'd':\n \t\tformat_decoration(sb, commit);\n \t\treturn 1;\n+\tcase 'g':\t\t/* reflog handle */\n+\t\tif (c->reflog_info)\n+\t\t\tget_reflog_selector(sb, c->reflog_info, c->dmode);\n+\t\treturn 1;\n+\tcase 'G':\t\t/* reflog message */\n+\t\tif (c->reflog_info)\n+\t\t\tget_reflog_message(sb, c->reflog_info);\n+\t\treturn 1;\n \t}\n \n \t/* For the rest we have to parse the commit header. */\n@@ -741,13 +751,15 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,\n \n void format_commit_message(const struct commit *commit,\n \t\t\t   const void *format, struct strbuf *sb,\n-\t\t\t   enum date_mode dmode)\n+\t\t\t   enum date_mode dmode,\n+\t\t\t   struct reflog_walk_info *reflog_info)\n {\n \tstruct format_commit_context context;\n \n \tmemset(&context, 0, sizeof(context));\n \tcontext.commit = commit;\n \tcontext.dmode = dmode;\n+\tcontext.reflog_info = reflog_info;\n \tstrbuf_expand(sb, format, format_commit_item, &context);\n }\n \n@@ -902,7 +914,8 @@ void pp_remainder(enum cmit_fmt fmt,\n void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,\n \t\t\t struct strbuf *sb, int abbrev,\n \t\t\t const char *subject, const char *after_subject,\n-\t\t\t enum date_mode dmode, int need_8bit_cte)\n+\t\t\t enum date_mode dmode, int need_8bit_cte,\n+\t\t\t struct reflog_walk_info *reflog_info)\n {\n \tunsigned long beginning_of_body;\n \tint indent = 4;\n@@ -911,7 +924,8 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,\n \tconst char *encoding;\n \n \tif (fmt == CMIT_FMT_USERFORMAT) {\n-\t\tformat_commit_message(commit, user_format, sb, dmode);\n+\t\tformat_commit_message(commit, user_format, sb, dmode,\n+\t\t\t\t      reflog_info);\n \t\treturn;\n \t}\n \ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 9478dbc..929f025 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -265,6 +265,22 @@ void get_reflog_selector(struct strbuf *sb,\n \tstrbuf_addch(sb, '}');\n }\n \n+void get_reflog_message(struct strbuf *sb,\n+\t\t\tstruct reflog_walk_info *reflog_info)\n+{\n+\tstruct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;\n+\tstruct reflog_info *info;\n+\n+\tif (!commit_reflog)\n+\t\treturn;\n+\n+\tinfo = &commit_reflog->reflogs->items[commit_reflog->recno+1];\n+\tsize_t len = strlen(info->message);\n+\tif (len > 0)\n+\t\tlen--;\n+\tstrbuf_add(sb, info->message, len);\n+}\n+\n void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,\n \tenum date_mode dmode)\n {\ndiff --git a/reflog-walk.h b/reflog-walk.h\nindex 74c9096..986121f 100644\n--- a/reflog-walk.h\n+++ b/reflog-walk.h\n@@ -3,6 +3,8 @@\n \n #include \"cache.h\"\n \n+struct reflog_walk_info;\n+\n extern void init_reflog_walk(struct reflog_walk_info** info);\n extern int add_reflog_for_walk(struct reflog_walk_info *info,\n \t\tstruct commit *commit, const char *name);\n@@ -10,5 +12,10 @@ 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, int,\n \t\tenum date_mode);\n+extern void get_reflog_message(struct strbuf *sb,\n+\t\tstruct reflog_walk_info *reflog_info);\n+extern void get_reflog_selector(struct strbuf *sb,\n+\t\tstruct reflog_walk_info *reflog_info,\n+\t\tenum date_mode dmode);\n \n #endif\n-- \n1.6.5.64.g01287\n"},{"id":"124759","messageId":"77e591b80021efc265fea1a101ce6b7124ea832e.1255380039.git.trast@student.ethz.ch","threadId":"21218","inReplyTo":"cover.1255380039.git.trast@student.ethz.ch","subject":"[RFC PATCH 3/5] stash: Use new %g/%G formats instead of sed","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-12T21:06:05Z","receivedAt":"2009-10-12T21:06:05Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"With the new formats, we can rewrite 'git stash list' in terms of an\nappropriate pretty format, instead of hand-editing with sed.  This has\nthe advantage that it obeys the normal settings for git-log, notably\nthe pager.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n git-stash.sh |    3 +--\n 1 files changed, 1 insertions(+), 2 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 4febbbf..8fbf10a 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -205,8 +205,7 @@ have_stash () {\n \n list_stash () {\n \thave_stash || return 0\n-\tgit log --no-color --pretty=oneline -g \"$@\" $ref_stash -- |\n-\tsed -n -e 's/^[.0-9a-f]* refs\\///p'\n+\tgit log --format=\"%g: %G\" -g \"$@\" $ref_stash\n }\n \n show_stash () {\n-- \n1.6.5.64.g01287\n"},{"id":"124751","messageId":"137df1f7295576345f5aefe46c882399e107c321.1255380039.git.trast@student.ethz.ch","threadId":"21218","inReplyTo":"cover.1255380039.git.trast@student.ethz.ch","subject":"[RFC PATCH 4/5] stash list: drop the default limit of 10 stashes","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-12T21:06:06Z","receivedAt":"2009-10-12T21:06:06Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"'git stash list' had an undocumented limit of 10 stashes, unless other\ngit-log arguments were specified.  This surprised at least one user,\nbut possibly served to cut the output below a screenful without using\na pager.\n\nSince the last commit, 'git stash list' will fire up a pager according\nto the same rules as the 'git log' it calls, so we can drop the limit.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n git-stash.sh |    5 -----\n 1 files changed, 0 insertions(+), 5 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 8fbf10a..08a7669 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -382,11 +382,6 @@ test -n \"$seen_non_option\" || set \"save\" \"$@\"\n case \"$1\" in\n list)\n \tshift\n-\tif test $# = 0\n-\tthen\n-\t\tset x -n 10\n-\t\tshift\n-\tfi\n \tlist_stash \"$@\"\n \t;;\n show)\n-- \n1.6.5.64.g01287\n"},{"id":"124754","messageId":"548bc3a41c03a049e782d5d04a34c3b26c0897d2.1255380039.git.trast@student.ethz.ch","threadId":"21218","inReplyTo":"cover.1255380039.git.trast@student.ethz.ch","subject":"[RFC PATCH 5/5] stash: change built-in ref to 'stash' instead of 'refs/stash'","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-12T21:06:07Z","receivedAt":"2009-10-12T21:06:07Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"'git stash list' now always shows 'refs/stash@{...}' instead of\n'stash@{...}', because that's what we specify for the ref.\n\nSince git checks .git/$ref, .git/refs/$ref and only then\n.git/refs/{branches,tags,remotes}, we can drop the prefix.  This only\naffects people who have .git/stash, who were never able to refer to\ntheir stashes by stash@{...}.  (Sadly, now they won't be able to use\ngit-stash anymore at all.)\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n git-stash.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 08a7669..8bf464b 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -19,7 +19,7 @@ cd_to_toplevel\n TMP=\"$GIT_DIR/.git-stash.$$\"\n trap 'rm -f \"$TMP-*\"' 0\n \n-ref_stash=refs/stash\n+ref_stash=stash\n \n if git config --get-colorbool color.interactive; then\n        help_color=\"$(git config --get-color color.interactive.help 'red bold')\"\n-- \n1.6.5.64.g01287\n"},{"id":"124764","messageId":"20091012213756.GA12166@coredump.intra.peff.net","threadId":"21218","inReplyTo":"cover.1255380039.git.trast@student.ethz.ch","subject":"Re: [RFC PATCH 0/5] Pretty formats for reflog data","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-10-12T21:37:56Z","receivedAt":"2009-10-12T21:37:56Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 12, 2009 at 11:02:29PM +0200, Thomas Rast wrote:\n\n> > Stash listing is internally just \"git log -g refs/stash\", so you can\n> > pass any formatting or limiting arguments you want there (see the git\n> > log documentation for ideas). If no arguments are given, we pass \"-10\".\n> \n> This seems fairly arbitrary, doesn't it?  My own working theory is\n> that Nanako put it in because the git-log|sed construct inherently\n> bars any way to a pager, so it needs to be cut short.\n\nYes, it's arbitrary, though it is probably a reasonable estimate for the\nintended use of stash. It's a stack, so you generally are only\ninterested in the last couple of entries.\n\nWhat's much worse though is that the logic is not \"if you told me how\nmany to show, show that; otherwise, show 10\".  Instead it is \"if you\ngave me no options, default the size of the list.  But if you gave me\nany options, even if they have nothing whatsoever to do with limiting\nthe size of the list, then show all\".\n\nSo something like \"git stash list --date=relative\" suddenly shows many more\nstashes than just \"git stash list\". It would be nice to fix that.\n\n> So suppose we could somehow get rid of the |sed... like if we had\n> --pretty specifiers for the reflog information.\n\nI'm not sure if people will like having a longer list in a pager than a\nshorter list without one (I personally can't remember ever using \"git\nstash list\", so I have no strong opinion).\n\nBut certainly the idea of adding pretty format specifiers to access\nreflog data seems like a good idea on its own.\n\n-Peff\n"},{"id":"124766","messageId":"200910122352.25658.trast@student.ethz.ch","threadId":"21218","inReplyTo":"20091012213756.GA12166@coredump.intra.peff.net","subject":"Re: [RFC PATCH 0/5] Pretty formats for reflog data","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-12T21:52:23Z","receivedAt":"2009-10-12T21:52:23Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Jeff King wrote:\n> \n> I'm not sure if people will like having a longer [stash] list in a\n> pager than a shorter list without one (I personally can't remember\n> ever using \"git stash list\", so I have no strong opinion).\n\nTrue.  Then again we patched git-stash(1) to recommend stash/pop over\nstash/apply, so we should actively show the user that s/he has a long\nstash list and may want to apply them somewhere.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"124929","messageId":"20091014045918.GA31810@coredump.intra.peff.net","threadId":"21218","inReplyTo":"e0321a8af8d702d24ace33510daff22d02f4e116.1255380039.git.trast@student.ethz.ch","subject":"Re: [RFC PATCH 2/5] Introduce new pretty formats %g and %G for reflog information","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-10-14T04:59:18Z","receivedAt":"2009-10-14T04:59:18Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 12, 2009 at 11:06:04PM +0200, Thomas Rast wrote:\n\n> Unfortunately, we also need to pass down the reflog_walk_info from\n> show_log(), so this commit touches a lot of (unrelated) callers to\n> pretty_print_commit() and format_commit_message() to accomodate the\n> extra argument.\n\nA while back I wanted to add a feature to pretty-printing, and I ran\ninto the same situation (though my feature never made it to the list).\nWe really end up passing around the same arguments over and over.  Maybe\nit makes sense instead of adding another argument to refactor into a\n\"pretty_print_context\" struct that contains all of the arguments and\ncurrent state.\n\nIt would be an even more invasive patch, but I think it would make\nthings more readable, and make future changes much easier to see.\n\n-Peff\n"},{"id":"124928","messageId":"20091014050038.GB31810@coredump.intra.peff.net","threadId":"21218","inReplyTo":"77e591b80021efc265fea1a101ce6b7124ea832e.1255380039.git.trast@student.ethz.ch","subject":"Re: [RFC PATCH 3/5] stash: Use new %g/%G formats instead of sed","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-10-14T05:00:38Z","receivedAt":"2009-10-14T05:00:38Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 12, 2009 at 11:06:05PM +0200, Thomas Rast wrote:\n\n>  list_stash () {\n>  \thave_stash || return 0\n> -\tgit log --no-color --pretty=oneline -g \"$@\" $ref_stash -- |\n> -\tsed -n -e 's/^[.0-9a-f]* refs\\///p'\n> +\tgit log --format=\"%g: %G\" -g \"$@\" $ref_stash\n\nYou dropped the trailing \"--\" which is needed for disambiguation.\n\n-Peff\n"},{"id":"124930","messageId":"20091014050248.GC31810@coredump.intra.peff.net","threadId":"21218","inReplyTo":"137df1f7295576345f5aefe46c882399e107c321.1255380039.git.trast@student.ethz.ch","subject":"Re: [RFC PATCH 4/5] stash list: drop the default limit of 10 stashes","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-10-14T05:02:48Z","receivedAt":"2009-10-14T05:02:48Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 12, 2009 at 11:06:06PM +0200, Thomas Rast wrote:\n\n> 'git stash list' had an undocumented limit of 10 stashes, unless other\n> git-log arguments were specified.  This surprised at least one user,\n> but possibly served to cut the output below a screenful without using\n> a pager.\n> \n> Since the last commit, 'git stash list' will fire up a pager according\n> to the same rules as the 'git log' it calls, so we can drop the limit.\n\nHaving slept on it, I think I agree that this is a good change. It fixes\nthe ugly corner cases I mentioned, and it is easier to explain.\n\n-Peff\n"},{"id":"124933","messageId":"20091014050645.GD31810@coredump.intra.peff.net","threadId":"21218","inReplyTo":"548bc3a41c03a049e782d5d04a34c3b26c0897d2.1255380039.git.trast@student.ethz.ch","subject":"Re: [RFC PATCH 5/5] stash: change built-in ref to 'stash' instead of 'refs/stash'","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-10-14T05:06:45Z","receivedAt":"2009-10-14T05:06:45Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 12, 2009 at 11:06:07PM +0200, Thomas Rast wrote:\n\n> 'git stash list' now always shows 'refs/stash@{...}' instead of\n> 'stash@{...}', because that's what we specify for the ref.\n> \n> Since git checks .git/$ref, .git/refs/$ref and only then\n> .git/refs/{branches,tags,remotes}, we can drop the prefix.  This only\n> affects people who have .git/stash, who were never able to refer to\n> their stashes by stash@{...}.  (Sadly, now they won't be able to use\n> git-stash anymore at all.)\n\nMaybe a better solution would be a \"short name\" variant for pretty\nformat specifiers. We already have %(refname) and %(refname:short) in\nfor-each-ref, where the latter cuts off \"refs/heads/\", \"refs/tags\", or\n\"refs/remotes/\" from the beginning. I'm not sure if it does just\n\"refs/\", but probably it should. It may even check for ambiguity, but\nI'd have to double-check the code.\n\nThe tricky part would be deciding on a syntax. This seems to come up a\nfair bit. I think there is room for somebody to suggest a more expansive\n--format syntax that can handle arbitrary arguments being given to\nexpansions (I think there was some discussion recently in a related\nthread about body indentation, but I haven't been following it too\nclosely).\n\n-Peff\n"},{"id":"124955","messageId":"7vd44qfidi.fsf@alter.siamese.dyndns.org","threadId":"21218","inReplyTo":"e0321a8af8d702d24ace33510daff22d02f4e116.1255380039.git.trast@student.ethz.ch","subject":"Re: [RFC PATCH 2/5] Introduce new pretty formats %g and %G for reflog information","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-14T09:13:29Z","receivedAt":"2009-10-14T09:13:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Squash this patch on top, as\n\n    cc1: warnings being treated as errors\n    reflog-walk.c: In function 'get_reflog_message':\n    reflog-walk.c:278: error: ISO C90 forbids mixed declarations and code\n\n---\n\n reflog-walk.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 929f025..5cbcb1a 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -270,12 +270,13 @@ void get_reflog_message(struct strbuf *sb,\n {\n \tstruct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;\n \tstruct reflog_info *info;\n+\tsize_t len;\n \n \tif (!commit_reflog)\n \t\treturn;\n \n \tinfo = &commit_reflog->reflogs->items[commit_reflog->recno+1];\n-\tsize_t len = strlen(info->message);\n+\tlen = strlen(info->message);\n \tif (len > 0)\n \t\tlen--;\n \tstrbuf_add(sb, info->message, len);\n"},{"id":"124959","messageId":"200910141158.35050.trast@student.ethz.ch","threadId":"21218","inReplyTo":"20091014045918.GA31810@coredump.intra.peff.net","subject":"Re: [RFC PATCH 2/5] Introduce new pretty formats %g and %G for reflog information","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-10-14T09:58:34Z","receivedAt":"2009-10-14T09:58:34Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Jeff King wrote:\n> On Mon, Oct 12, 2009 at 11:06:04PM +0200, Thomas Rast wrote:\n> \n> > Unfortunately, we also need to pass down the reflog_walk_info from\n> > show_log(), so this commit touches a lot of (unrelated) callers to\n> > pretty_print_commit() and format_commit_message() to accomodate the\n> > extra argument.\n> \n> A while back I wanted to add a feature to pretty-printing, and I ran\n> into the same situation (though my feature never made it to the list).\n> We really end up passing around the same arguments over and over.  Maybe\n> it makes sense instead of adding another argument to refactor into a\n> \"pretty_print_context\" struct that contains all of the arguments and\n> current state.\n> \n> It would be an even more invasive patch, but I think it would make\n> things more readable, and make future changes much easier to see.\n\nOk, I'll try for the next round.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"}]}