git log --author=me

2015-11-02 Thread Harry Jeffery

Hi,

I've written a patch that allows `me` to be used as shorthand for 
$(user.name) or $(user.email) in the `--author` and `--commiter` fields.


The purpose being to make finding your own commits quicker and easier:
git log --author=me

Is this a change that would be accepted if submitted? The only thing 
it's currently missing is unit tests.


Regards,
Harry
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4] pretty: add %D format specifier

2014-09-18 Thread Harry Jeffery
Add a new format specifier, '%D' that is identical in behaviour to '%d',
except that it does not include the ' (' prefix or ')' suffix provided
by '%d'.

Signed-off-by: Harry Jeffery 
---
 Documentation/pretty-formats.txt |  6 --
 log-tree.c   | 17 +
 log-tree.h   |  8 +++-
 pretty.c |  4 
 t/t4205-log-pretty-formats.sh| 11 +++
 5 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index eac7909..2632e1a 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -128,6 +128,7 @@ The placeholders are:
 - '%ct': committer date, UNIX timestamp
 - '%ci': committer date, ISO 8601 format
 - '%d': ref names, like the --decorate option of linkgit:git-log[1]
+- '%D': ref names without the " (", ")" wrapping.
 - '%e': encoding
 - '%s': subject
 - '%f': sanitized subject line, suitable for a filename
@@ -182,8 +183,9 @@ The placeholders are:
 NOTE: Some placeholders may depend on other options given to the
 revision traversal engine. For example, the `%g*` reflog options will
 insert an empty string unless we are traversing reflog entries (e.g., by
-`git log -g`). The `%d` placeholder will use the "short" decoration
-format if `--decorate` was not already provided on the command line.
+`git log -g`). The `%d` and `%D` placeholders will use the "short"
+decoration format if `--decorate` was not already provided on the command
+line.
 
 If you add a `+` (plus sign) after '%' of a placeholder, a line-feed
 is inserted immediately before the expansion if and only if the
diff --git a/log-tree.c b/log-tree.c
index 95e9b1d..8d05bb3 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -179,14 +179,16 @@ static void show_children(struct rev_info *opt, struct 
commit *commit, int abbre
 }
 
 /*
- * The caller makes sure there is no funny color before
- * calling. format_decorations makes sure the same after return.
+ * The caller makes sure there is no funny color before calling.
+ * format_decorations_extended makes sure the same after return.
  */
-void format_decorations(struct strbuf *sb,
+void format_decorations_extended(struct strbuf *sb,
const struct commit *commit,
-   int use_color)
+   int use_color,
+   const char *prefix,
+   const char *separator,
+   const char *suffix)
 {
-   const char *prefix;
struct name_decoration *decoration;
const char *color_commit =
diff_get_color(use_color, DIFF_COMMIT);
@@ -196,7 +198,6 @@ void format_decorations(struct strbuf *sb,
decoration = lookup_decoration(&name_decoration, &commit->object);
if (!decoration)
return;
-   prefix = " (";
while (decoration) {
strbuf_addstr(sb, color_commit);
strbuf_addstr(sb, prefix);
@@ -205,11 +206,11 @@ void format_decorations(struct strbuf *sb,
strbuf_addstr(sb, "tag: ");
strbuf_addstr(sb, decoration->name);
strbuf_addstr(sb, color_reset);
-   prefix = ", ";
+   prefix = separator;
decoration = decoration->next;
}
strbuf_addstr(sb, color_commit);
-   strbuf_addch(sb, ')');
+   strbuf_addstr(sb, suffix);
strbuf_addstr(sb, color_reset);
 }
 
diff --git a/log-tree.h b/log-tree.h
index d6ecd4d..b26160c 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -13,7 +13,13 @@ int log_tree_diff_flush(struct rev_info *);
 int log_tree_commit(struct rev_info *, struct commit *);
 int log_tree_opt_parse(struct rev_info *, const char **, int);
 void show_log(struct rev_info *opt);
-void format_decorations(struct strbuf *sb, const struct commit *commit, int 
use_color);
+void format_decorations_extended(struct strbuf *sb, const struct commit 
*commit,
+int use_color,
+const char *prefix,
+const char *separator,
+const char *suffix);
+#define format_decorations(strbuf, commit, color) \
+format_decorations_extended((strbuf), (commit), 
(color), " (", ", ", ")")
 void show_decorations(struct rev_info *opt, struct commit *commit);
 void log_write_email_headers(struct rev_info *opt, struct commit *commit,
 const char **subject_p,
diff --git a/pretty.c b/pretty.c
index 44b9f64..46d65b9 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1197,6 +1197,10 @@ static size_t format_commit_one(

[PATCH v3] pretty: add %D format specifier

2014-09-16 Thread Harry Jeffery
Add a new format specifier, '%D' that is identical in behaviour to '%d',
except that it does not include the ' (' prefix or ')' suffix provided
by '%d'.

Signed-off-by: Harry Jeffery 
---
 Documentation/pretty-formats.txt |  6 --
 log-tree.c   | 24 +---
 log-tree.h   |  8 +++-
 pretty.c |  4 
 t/t4205-log-pretty-formats.sh| 11 +++
 5 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index eac7909..2632e1a 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -128,6 +128,7 @@ The placeholders are:
 - '%ct': committer date, UNIX timestamp
 - '%ci': committer date, ISO 8601 format
 - '%d': ref names, like the --decorate option of linkgit:git-log[1]
+- '%D': ref names without the " (", ")" wrapping.
 - '%e': encoding
 - '%s': subject
 - '%f': sanitized subject line, suitable for a filename
@@ -182,8 +183,9 @@ The placeholders are:
 NOTE: Some placeholders may depend on other options given to the
 revision traversal engine. For example, the `%g*` reflog options will
 insert an empty string unless we are traversing reflog entries (e.g., by
-`git log -g`). The `%d` placeholder will use the "short" decoration
-format if `--decorate` was not already provided on the command line.
+`git log -g`). The `%d` and `%D` placeholders will use the "short"
+decoration format if `--decorate` was not already provided on the command
+line.
 
 If you add a `+` (plus sign) after '%' of a placeholder, a line-feed
 is inserted immediately before the expansion if and only if the
diff --git a/log-tree.c b/log-tree.c
index 95e9b1d..61d1dea 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -179,14 +179,16 @@ static void show_children(struct rev_info *opt, struct 
commit *commit, int abbre
 }
 
 /*
- * The caller makes sure there is no funny color before
- * calling. format_decorations makes sure the same after return.
+ * The caller makes sure there is no funny color before calling.
+ * format_decorations_extended makes sure the same after return.
  */
-void format_decorations(struct strbuf *sb,
+void format_decorations_extended(struct strbuf *sb,
const struct commit *commit,
-   int use_color)
+   int use_color,
+   const char *prefix,
+   const char *separator,
+   const char *suffix)
 {
-   const char *prefix;
struct name_decoration *decoration;
const char *color_commit =
diff_get_color(use_color, DIFF_COMMIT);
@@ -196,20 +198,20 @@ void format_decorations(struct strbuf *sb,
decoration = lookup_decoration(&name_decoration, &commit->object);
if (!decoration)
return;
-   prefix = " (";
+   strbuf_addstr(sb, color_commit);
+   strbuf_addstr(sb, prefix);
while (decoration) {
-   strbuf_addstr(sb, color_commit);
-   strbuf_addstr(sb, prefix);
strbuf_addstr(sb, decorate_get_color(use_color, 
decoration->type));
if (decoration->type == DECORATION_REF_TAG)
strbuf_addstr(sb, "tag: ");
strbuf_addstr(sb, decoration->name);
strbuf_addstr(sb, color_reset);
-   prefix = ", ";
+   strbuf_addstr(sb, color_commit);
+   if (decoration->next)
+   strbuf_addstr(sb, separator);
decoration = decoration->next;
}
-   strbuf_addstr(sb, color_commit);
-   strbuf_addch(sb, ')');
+   strbuf_addstr(sb, suffix);
strbuf_addstr(sb, color_reset);
 }
 
diff --git a/log-tree.h b/log-tree.h
index d6ecd4d..b26160c 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -13,7 +13,13 @@ int log_tree_diff_flush(struct rev_info *);
 int log_tree_commit(struct rev_info *, struct commit *);
 int log_tree_opt_parse(struct rev_info *, const char **, int);
 void show_log(struct rev_info *opt);
-void format_decorations(struct strbuf *sb, const struct commit *commit, int 
use_color);
+void format_decorations_extended(struct strbuf *sb, const struct commit 
*commit,
+int use_color,
+const char *prefix,
+const char *separator,
+const char *suffix);
+#define format_decorations(strbuf, commit, color) \
+format_decorations_extended((strbuf), (commit), 
(color), " (", ", ", ")")
 void show_decorations(struct rev_info *opt, struct commit *commit);
 void log_write_email_h

[PATCH v2] pretty: add %D format specifier

2014-09-15 Thread Harry Jeffery

Add a new format specifier, '%D' that is identical in behaviour to '%d',
except that it does not include the ' (' prefix or ')' suffix provided
by '%d'.

Signed-off-by: Harry Jeffery 
---
 Documentation/pretty-formats.txt |  6 --
 log-tree.c   | 24 +---
 log-tree.h   |  8 +++-
 pretty.c |  4 
 t/t4205-log-pretty-formats.sh| 11 +++
 5 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/Documentation/pretty-formats.txt 
b/Documentation/pretty-formats.txt

index eac7909..2632e1a 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -128,6 +128,7 @@ The placeholders are:
 - '%ct': committer date, UNIX timestamp
 - '%ci': committer date, ISO 8601 format
 - '%d': ref names, like the --decorate option of linkgit:git-log[1]
+- '%D': ref names without the " (", ")" wrapping.
 - '%e': encoding
 - '%s': subject
 - '%f': sanitized subject line, suitable for a filename
@@ -182,8 +183,9 @@ The placeholders are:
 NOTE: Some placeholders may depend on other options given to the
 revision traversal engine. For example, the `%g*` reflog options will
 insert an empty string unless we are traversing reflog entries (e.g., by
-`git log -g`). The `%d` placeholder will use the "short" decoration
-format if `--decorate` was not already provided on the command line.
+`git log -g`). The `%d` and `%D` placeholders will use the "short"
+decoration format if `--decorate` was not already provided on the command
+line.

 If you add a `+` (plus sign) after '%' of a placeholder, a line-feed
 is inserted immediately before the expansion if and only if the
diff --git a/log-tree.c b/log-tree.c
index 95e9b1d..61d1dea 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -179,14 +179,16 @@ static void show_children(struct rev_info *opt, 
struct commit *commit, int abbre

 }

 /*
- * The caller makes sure there is no funny color before
- * calling. format_decorations makes sure the same after return.
+ * The caller makes sure there is no funny color before calling.
+ * format_decorations_extended makes sure the same after return.
  */
-void format_decorations(struct strbuf *sb,
+void format_decorations_extended(struct strbuf *sb,
const struct commit *commit,
-   int use_color)
+   int use_color,
+   const char *prefix,
+   const char *separator,
+   const char *suffix)
 {
-   const char *prefix;
struct name_decoration *decoration;
const char *color_commit =
diff_get_color(use_color, DIFF_COMMIT);
@@ -196,20 +198,20 @@ void format_decorations(struct strbuf *sb,
decoration = lookup_decoration(&name_decoration, &commit->object);
if (!decoration)
return;
-   prefix = " (";
+   strbuf_addstr(sb, color_commit);
+   strbuf_addstr(sb, prefix);
while (decoration) {
-   strbuf_addstr(sb, color_commit);
-   strbuf_addstr(sb, prefix);
strbuf_addstr(sb, decorate_get_color(use_color, 
decoration->type));
if (decoration->type == DECORATION_REF_TAG)
strbuf_addstr(sb, "tag: ");
strbuf_addstr(sb, decoration->name);
strbuf_addstr(sb, color_reset);
-   prefix = ", ";
+   strbuf_addstr(sb, color_commit);
+   if (decoration->next)
+   strbuf_addstr(sb, separator);
decoration = decoration->next;
}
-   strbuf_addstr(sb, color_commit);
-   strbuf_addch(sb, ')');
+   strbuf_addstr(sb, suffix);
strbuf_addstr(sb, color_reset);
 }

diff --git a/log-tree.h b/log-tree.h
index d6ecd4d..b26160c 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -13,7 +13,13 @@ int log_tree_diff_flush(struct rev_info *);
 int log_tree_commit(struct rev_info *, struct commit *);
 int log_tree_opt_parse(struct rev_info *, const char **, int);
 void show_log(struct rev_info *opt);
-void format_decorations(struct strbuf *sb, const struct commit *commit, 
int use_color);
+void format_decorations_extended(struct strbuf *sb, const struct commit 
*commit,

+int use_color,
+const char *prefix,
+const char *separator,
+const char *suffix);
+#define format_decorations(strbuf, commit, color) \
+			 format_decorations_extended((strbuf), (commit), (color), " (", 
", ", ")")

 void show_decorations(struct rev_info *opt, struct commit *commit);
 void log_write_email_headers(struct rev_

Re: [PATCH 2/2] pretty: add %D format specifier

2014-09-11 Thread Harry Jeffery

On 11/09/14 17:56, Junio C Hamano wrote:
> Because patch 1/2 alone does not make much sense without 2/2, it
> probably would have been better to do these as a single patch.

Would you like me to resubmit it as a single patch, or are you applying 
them as is?


> And of course a few additional tests to t4205 would not hurt ;-)

Sure. Should the tests be in the same patch, or a subsequent one?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] pretty: add %D format specifier

2014-09-10 Thread Harry Jeffery

%d prints decorations wrapped by " (" and ")". %D provides the same
output without the parenthesis, making " (%D)" and "%d" equivalent to
one another.

Signed-off-by: Harry Jeffery 
---
 Documentation/pretty-formats.txt | 6 --
 pretty.c | 4 
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Documentation/pretty-formats.txt 
b/Documentation/pretty-formats.txt

index eac7909..2632e1a 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -128,6 +128,7 @@ The placeholders are:
 - '%ct': committer date, UNIX timestamp
 - '%ci': committer date, ISO 8601 format
 - '%d': ref names, like the --decorate option of linkgit:git-log[1]
+- '%D': ref names without the " (", ")" wrapping.
 - '%e': encoding
 - '%s': subject
 - '%f': sanitized subject line, suitable for a filename
@@ -182,8 +183,9 @@ The placeholders are:
 NOTE: Some placeholders may depend on other options given to the
 revision traversal engine. For example, the `%g*` reflog options will
 insert an empty string unless we are traversing reflog entries (e.g., by
-`git log -g`). The `%d` placeholder will use the "short" decoration
-format if `--decorate` was not already provided on the command line.
+`git log -g`). The `%d` and `%D` placeholders will use the "short"
+decoration format if `--decorate` was not already provided on the command
+line.

 If you add a `+` (plus sign) after '%' of a placeholder, a line-feed
 is inserted immediately before the expansion if and only if the
diff --git a/pretty.c b/pretty.c
index e4dc093..a75ad0d 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1197,6 +1197,10 @@ static size_t format_commit_one(struct strbuf 
*sb, /* in UTF-8 */

load_ref_decorations(DECORATE_SHORT_REFS);
format_decorations(sb, commit, c->auto_color, " (", ", ", ")");
return 1;
+   case 'D':
+   load_ref_decorations(DECORATE_SHORT_REFS);
+   format_decorations(sb, commit, c->auto_color, "", ", ", "");
+   return 1;
case 'g':   /* reflog info */
switch(placeholder[1]) {
case 'd':   /* reflog selector */
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] log-tree: make format_decorations more flexible

2014-09-10 Thread Harry Jeffery

The prefix, separator and suffix for decorations are hard-coded. Make
format_decorations more flexible by having the caller specify the
prefix, separator and suffix.

Signed-off-by: Harry Jeffery 
---
 log-tree.c | 16 +---
 log-tree.h |  2 +-
 pretty.c   |  2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/log-tree.c b/log-tree.c
index 95e9b1d..860694c 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -184,9 +184,11 @@ static void show_children(struct rev_info *opt, 
struct commit *commit, int abbre

  */
 void format_decorations(struct strbuf *sb,
const struct commit *commit,
-   int use_color)
+   int use_color,
+   const char* prefix,
+   const char* sep,
+   const char* suffix)
 {
-   const char *prefix;
struct name_decoration *decoration;
const char *color_commit =
diff_get_color(use_color, DIFF_COMMIT);
@@ -196,20 +198,20 @@ void format_decorations(struct strbuf *sb,
decoration = lookup_decoration(&name_decoration, &commit->object);
if (!decoration)
return;
-   prefix = " (";
+   strbuf_addstr(sb, prefix);
while (decoration) {
strbuf_addstr(sb, color_commit);
-   strbuf_addstr(sb, prefix);
strbuf_addstr(sb, decorate_get_color(use_color, 
decoration->type));
if (decoration->type == DECORATION_REF_TAG)
strbuf_addstr(sb, "tag: ");
strbuf_addstr(sb, decoration->name);
+   if(decoration->next)
+   strbuf_addstr(sb, sep);
strbuf_addstr(sb, color_reset);
-   prefix = ", ";
decoration = decoration->next;
}
strbuf_addstr(sb, color_commit);
-   strbuf_addch(sb, ')');
+   strbuf_addstr(sb, suffix);
strbuf_addstr(sb, color_reset);
 }

@@ -221,7 +223,7 @@ void show_decorations(struct rev_info *opt, struct 
commit *commit)

printf("\t%s", (char *) commit->util);
if (!opt->show_decorations)
return;
-   format_decorations(&sb, commit, opt->diffopt.use_color);
+   format_decorations(&sb, commit, opt->diffopt.use_color, " (", ", ", 
")");
fputs(sb.buf, stdout);
strbuf_release(&sb);
 }
diff --git a/log-tree.h b/log-tree.h
index d6ecd4d..4816911 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -13,7 +13,7 @@ int log_tree_diff_flush(struct rev_info *);
 int log_tree_commit(struct rev_info *, struct commit *);
 int log_tree_opt_parse(struct rev_info *, const char **, int);
 void show_log(struct rev_info *opt);
-void format_decorations(struct strbuf *sb, const struct commit *commit, 
int use_color);
+void format_decorations(struct strbuf *sb, const struct commit *commit, 
int use_color, const char* prefix, const char* sep, const char* suffix);

 void show_decorations(struct rev_info *opt, struct commit *commit);
 void log_write_email_headers(struct rev_info *opt, struct commit *commit,
 const char **subject_p,
diff --git a/pretty.c b/pretty.c
index 44b9f64..e4dc093 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1195,7 +1195,7 @@ static size_t format_commit_one(struct strbuf *sb, 
/* in UTF-8 */

return 1;
case 'd':
load_ref_decorations(DECORATE_SHORT_REFS);
-   format_decorations(sb, commit, c->auto_color);
+   format_decorations(sb, commit, c->auto_color, " (", ", ", ")");
return 1;
case 'g':   /* reflog info */
switch(placeholder[1]) {
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pretty-format: add append line-feed format specifier

2014-09-09 Thread Harry Jeffery

On 09/09/14 22:45, Jeff King wrote:

Yeah, that was my thought on reading the initial patch, too. Why limit
ourselves to newlines and spaces. I'd much rather have full conditional
expansion, like "${foo:+prefix $foo suffix}" in the shell.

Something like the patch below might work, but I didn't test it very
thoroughly (and note the comments, which might need dealing with). Maybe
it would make a sensible base for Harry to build on if he wants to
pursue this.


I definitely prefer your more general solution to my 
bare-minimum-to-scratch-itch patch. I'd certainly be willing to take 
your patch and expand upon it (pun unintended) once Junio has weighed in 
on your suggestions.



You could also make "%d" more flexible with it. We unconditionally
include the " (...)" wrapper when expanding it. But assuming we
introduced a "%D" that is _just_ the decoration names, you could do:

   %if(%D, (%D))

to get the same effect with much more flexibility.


Regardless of what happens with the conditional expansion I think it 
would definitely be a useful addition to be able to print the decorators 
without the " (...)" wrapper. I think it's general enough that it'd 
warrant its own separate patch rather than being part of a patch series 
for the conditional expansion.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pretty-format: add append line-feed format specifier

2014-09-09 Thread Harry Jeffery

On 09/09/14 20:15, Junio C Hamano wrote:

Is this different from "%n%-d"?



Yes. "%n%-d" will place the newline before the expansion, not after.

log --decorate --pretty=format:"%n%-d%h\\ %t\\ [%cn]\\ %s"
---

 (HEAD, upstream/master, master)85f0837 c29da1d [Junio C Hamano] Start 
the post-2.1 cycle

 f655651 4027a43 [Junio C Hamano] Merge branch 'rs/strbuf-getcwd'
 51eeaea 1f4970c [Junio C Hamano] Merge branch 'ta/pretty-parse-config'
 4740891 8961621 [Junio C Hamano] Merge branch 'bc/archive-pax-header-mode'
---

log --decorate --pretty=format:"%_d%%h\\ %t\\ [%cn]\\ %s"
---
 (HEAD, upstream/master, master)
85f0837 c29da1d [Junio C Hamano] Start the post-2.1 cycle
f655651 4027a43 [Junio C Hamano] Merge branch 'rs/strbuf-getcwd'
51eeaea 1f4970c [Junio C Hamano] Merge branch 'ta/pretty-parse-config'
4740891 8961621 [Junio C Hamano] Merge branch 'bc/archive-pax-header-mode'
---

The latter is the output I've been trying to accomplish, and as far as I 
can tell, this patch is the only way to achieve it.


Well, you can do "%d%n" but that will put a blank line before every 
commit that doesn't have a ref.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] pretty-format: add append line-feed format specifier

2014-09-09 Thread Harry Jeffery

Add a new format prefix `_` that causes a line-feed to be inserted
immediately after an expansion if the expansion expands to a non-empty
string. This is useful for when you would like a line for an expansion
to be prepended, but only when the expansion expands to a non empty
string, such as inserting a '%_d' expansion before a commit to show any
refs pointing towards it.

Signed-off-by: Harry Jeffery 
---
 Documentation/pretty-formats.txt |  4 
 pretty.c | 10 --
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Documentation/pretty-formats.txt 
b/Documentation/pretty-formats.txt

index 85d6353..842cd17 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -197,6 +197,10 @@ If you add a ` ` (space) after '%' of a 
placeholder, a space

 is inserted immediately before the expansion if and only if the
 placeholder expands to a non-empty string.

+If you add a `_` (underscore) after '%' of a placeholder, a line-feed
+is inserted immediately after the expansion if and only if the
+placeholder expands to a non-empty string.
+
 * 'tformat:'
 +
 The 'tformat:' format works exactly like 'format:', except that it
diff --git a/pretty.c b/pretty.c
index 44b9f64..ddb930d 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1416,7 +1416,8 @@ static size_t format_commit_item(struct strbuf 
*sb, /* in UTF-8 */

NO_MAGIC,
ADD_LF_BEFORE_NON_EMPTY,
DEL_LF_BEFORE_EMPTY,
-   ADD_SP_BEFORE_NON_EMPTY
+   ADD_SP_BEFORE_NON_EMPTY,
+   ADD_LF_AFTER_NON_EMPTY
} magic = NO_MAGIC;

switch (placeholder[0]) {
@@ -1429,6 +1430,9 @@ static size_t format_commit_item(struct strbuf 
*sb, /* in UTF-8 */

case ' ':
magic = ADD_SP_BEFORE_NON_EMPTY;
break;
+   case '_':
+   magic = ADD_LF_AFTER_NON_EMPTY;
+   break;
default:
break;
}
@@ -1449,6 +1453,8 @@ static size_t format_commit_item(struct strbuf 
*sb, /* in UTF-8 */

} else if (orig_len != sb->len) {
if (magic == ADD_LF_BEFORE_NON_EMPTY)
strbuf_insert(sb, orig_len, "\n", 1);
+   else if (magic == ADD_LF_AFTER_NON_EMPTY)
+   strbuf_addch(sb, '\n');
else if (magic == ADD_SP_BEFORE_NON_EMPTY)
strbuf_insert(sb, orig_len, " ", 1);
}
@@ -1460,7 +1466,7 @@ static size_t userformat_want_item(struct strbuf 
*sb, const char *placeholder,

 {
struct userformat_want *w = context;

-   if (*placeholder == '+' || *placeholder == '-' || *placeholder == ' ')
+	if (*placeholder == '+' || *placeholder == '-' || *placeholder == ' ' 
|| *placeholder == '_')

placeholder++;

switch (*placeholder) {
--
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html