summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-06-22 16:45:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-06-22 16:45:22 (GMT)
commit223a923c37f76ee91eb6a9cb77ce6d31dcf939cc (patch)
treeb56a1133686e8a283ed13141459a73aa7056c74b /pretty.c
parent5bfd53629e93113a17fe7d6a7a24554dc3c17cdb (diff)
parent7b88176e9bce658fd44c2192c1b7aa6e612ee0c2 (diff)
downloadgit-223a923c37f76ee91eb6a9cb77ce6d31dcf939cc.zip
git-223a923c37f76ee91eb6a9cb77ce6d31dcf939cc.tar.gz
git-223a923c37f76ee91eb6a9cb77ce6d31dcf939cc.tar.bz2
Merge branch 'mg/pretty-magic-space'
* mg/pretty-magic-space: pretty: Introduce ' ' modifier to add space if non-empty Conflicts: pretty.c
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/pretty.c b/pretty.c
index 4b85373..f85444b 100644
--- a/pretty.c
+++ b/pretty.c
@@ -941,7 +941,8 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
enum {
NO_MAGIC,
ADD_LF_BEFORE_NON_EMPTY,
- DEL_LF_BEFORE_EMPTY
+ DEL_LF_BEFORE_EMPTY,
+ ADD_SP_BEFORE_NON_EMPTY
} magic = NO_MAGIC;
switch (placeholder[0]) {
@@ -951,6 +952,9 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
case '+':
magic = ADD_LF_BEFORE_NON_EMPTY;
break;
+ case ' ':
+ magic = ADD_SP_BEFORE_NON_EMPTY;
+ break;
default:
break;
}
@@ -965,8 +969,11 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
if ((orig_len == sb->len) && magic == DEL_LF_BEFORE_EMPTY) {
while (sb->len && sb->buf[sb->len - 1] == '\n')
strbuf_setlen(sb, sb->len - 1);
- } else if ((orig_len != sb->len) && magic == ADD_LF_BEFORE_NON_EMPTY) {
- strbuf_insert(sb, orig_len, "\n", 1);
+ } else if (orig_len != sb->len) {
+ if (magic == ADD_LF_BEFORE_NON_EMPTY)
+ strbuf_insert(sb, orig_len, "\n", 1);
+ else if (magic == ADD_SP_BEFORE_NON_EMPTY)
+ strbuf_insert(sb, orig_len, " ", 1);
}
return consumed + 1;
}
@@ -976,7 +983,7 @@ static size_t userformat_want_item(struct strbuf *sb, const char *placeholder,
{
struct userformat_want *w = context;
- if (*placeholder == '+' || *placeholder == '-')
+ if (*placeholder == '+' || *placeholder == '-' || *placeholder == ' ')
placeholder++;
switch (*placeholder) {