Skip to content

Commit 5f809ff

Browse files
committed
fixup tr/stash-format merge
2 parents d39d667 + b7b1038 commit 5f809ff

19 files changed

+192
-79
lines changed

Documentation/git-stash.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ stash@{1}: On master: 9cc0589... Add git-stash
7878
----------------------------------------------------------------
7979
+
8080
The command takes options applicable to the 'git-log'
81-
command to control what is shown and how. If no options are set, the
82-
default is `-n 10`. See linkgit:git-log[1].
81+
command to control what is shown and how. See linkgit:git-log[1].
8382

8483
show [<stash>]::
8584

Documentation/pretty-formats.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ The placeholders are:
123123
- '%s': subject
124124
- '%f': sanitized subject line, suitable for a filename
125125
- '%b': body
126+
- '%gD': reflog selector, e.g., `refs/stash@\{1\}`
127+
- '%gd': shortened reflog selector, e.g., `stash@\{1\}`
128+
- '%gs': reflog subject
126129
- '%Cred': switch color to red
127130
- '%Cgreen': switch color to green
128131
- '%Cblue': switch color to blue
@@ -132,6 +135,12 @@ The placeholders are:
132135
- '%n': newline
133136
- '%x00': print a byte from a hex code
134137

138+
NOTE: Some placeholders may depend on other options given to the
139+
revision traversal engine. For example, the `%g*` reflog options will
140+
insert an empty string unless we are traversing reflog entries (e.g., by
141+
`git log -g`). The `%d` placeholder will use the "short" decoration
142+
format if `--decorate` was not already provided on the command line.
143+
135144
* 'tformat:'
136145
+
137146
The 'tformat:' format works exactly like 'format:', except that it

archive.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ static void format_subst(const struct commit *commit,
3131
{
3232
char *to_free = NULL;
3333
struct strbuf fmt = STRBUF_INIT;
34+
struct pretty_print_context ctx = {0};
35+
ctx.date_mode = DATE_NORMAL;
3436

3537
if (src == buf->buf)
3638
to_free = strbuf_detach(buf, NULL);
@@ -48,7 +50,7 @@ static void format_subst(const struct commit *commit,
4850
strbuf_add(&fmt, b + 8, c - b - 8);
4951

5052
strbuf_add(buf, src, b - src);
51-
format_commit_message(commit, fmt.buf, buf, DATE_NORMAL);
53+
format_commit_message(commit, fmt.buf, buf, &ctx);
5254
len -= c + 1 - src;
5355
src = c + 1;
5456
}

builtin-branch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,9 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
387387

388388
commit = item->commit;
389389
if (commit && !parse_commit(commit)) {
390+
struct pretty_print_context ctx = {0};
390391
pretty_print_commit(CMIT_FMT_ONELINE, commit,
391-
&subject, 0, NULL, NULL, 0, 0);
392+
&subject, &ctx);
392393
sub = subject.buf;
393394
}
394395

builtin-checkout.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,9 @@ static void show_local_changes(struct object *head)
302302
static void describe_detached_head(char *msg, struct commit *commit)
303303
{
304304
struct strbuf sb = STRBUF_INIT;
305+
struct pretty_print_context ctx = {0};
305306
parse_commit(commit);
306-
pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, 0, NULL, NULL, 0, 0);
307+
pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, &ctx);
307308
fprintf(stderr, "%s %s... %s\n", msg,
308309
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV), sb.buf);
309310
strbuf_release(&sb);

builtin-commit.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,10 @@ static const char *find_author_by_nickname(const char *name)
725725
prepare_revision_walk(&revs);
726726
commit = get_revision(&revs);
727727
if (commit) {
728+
struct pretty_print_context ctx = {0};
729+
ctx.date_mode = DATE_NORMAL;
728730
strbuf_release(&buf);
729-
format_commit_message(commit, "%an <%ae>", &buf, DATE_NORMAL);
731+
format_commit_message(commit, "%an <%ae>", &buf, &ctx);
730732
return strbuf_detach(&buf, NULL);
731733
}
732734
die("No existing author found with '%s'", name);
@@ -983,8 +985,10 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
983985
initial_commit ? " (root-commit)" : "");
984986

985987
if (!log_tree_commit(&rev, commit)) {
988+
struct pretty_print_context ctx = {0};
986989
struct strbuf buf = STRBUF_INIT;
987-
format_commit_message(commit, format + 7, &buf, DATE_NORMAL);
990+
ctx.date_mode = DATE_NORMAL;
991+
format_commit_message(commit, format + 7, &buf, &ctx);
988992
printf("%s\n", buf.buf);
989993
strbuf_release(&buf);
990994
}

builtin-log.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,8 +1304,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
13041304

13051305
if (verbose) {
13061306
struct strbuf buf = STRBUF_INIT;
1307+
struct pretty_print_context ctx = {0};
13071308
pretty_print_commit(CMIT_FMT_ONELINE, commit,
1308-
&buf, 0, NULL, NULL, 0, 0);
1309+
&buf, &ctx);
13091310
printf("%c %s %s\n", sign,
13101311
sha1_to_hex(commit->object.sha1), buf.buf);
13111312
strbuf_release(&buf);

builtin-merge.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ static void squash_message(void)
264264
struct strbuf out = STRBUF_INIT;
265265
struct commit_list *j;
266266
int fd;
267+
struct pretty_print_context ctx = {0};
267268

268269
printf("Squash commit -- not updating HEAD\n");
269270
fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666);
@@ -285,13 +286,15 @@ static void squash_message(void)
285286
if (prepare_revision_walk(&rev))
286287
die("revision walk setup failed");
287288

289+
ctx.abbrev = rev.abbrev;
290+
ctx.date_mode = rev.date_mode;
291+
288292
strbuf_addstr(&out, "Squashed commit of the following:\n");
289293
while ((commit = get_revision(&rev)) != NULL) {
290294
strbuf_addch(&out, '\n');
291295
strbuf_addf(&out, "commit %s\n",
292296
sha1_to_hex(commit->object.sha1));
293-
pretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,
294-
NULL, NULL, rev.date_mode, 0);
297+
pretty_print_commit(rev.commit_format, commit, &out, &ctx);
295298
}
296299
if (write(fd, out.buf, out.len) < 0)
297300
die_errno("Writing SQUASH_MSG");

builtin-rev-list.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ static void show_commit(struct commit *commit, void *data)
9696

9797
if (revs->verbose_header && commit->buffer) {
9898
struct strbuf buf = STRBUF_INIT;
99-
pretty_print_commit(revs->commit_format, commit,
100-
&buf, revs->abbrev, NULL, NULL,
101-
revs->date_mode, 0);
99+
struct pretty_print_context ctx = {0};
100+
ctx.abbrev = revs->abbrev;
101+
ctx.date_mode = revs->date_mode;
102+
pretty_print_commit(revs->commit_format, commit, &buf, &ctx);
102103
if (revs->graph) {
103104
if (buf.len) {
104105
if (revs->commit_format != CMIT_FMT_ONELINE)

builtin-shortlog.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,12 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
158158
sha1_to_hex(commit->object.sha1));
159159
if (log->user_format) {
160160
struct strbuf buf = STRBUF_INIT;
161-
162-
pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf,
163-
DEFAULT_ABBREV, "", "", DATE_NORMAL, 0);
161+
struct pretty_print_context ctx = {0};
162+
ctx.abbrev = DEFAULT_ABBREV;
163+
ctx.subject = "";
164+
ctx.after_subject = "";
165+
ctx.date_mode = DATE_NORMAL;
166+
pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf, &ctx);
164167
insert_one_record(log, author, buf.buf);
165168
strbuf_release(&buf);
166169
return;

0 commit comments

Comments
 (0)