]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'eb/unpretty-b-format'
authorJunio C Hamano <gitster@pobox.com>
Sun, 9 May 2010 05:36:40 +0000 (22:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 9 May 2010 05:36:40 +0000 (22:36 -0700)
* eb/unpretty-b-format:
  Add `%B' in format strings for raw commit body in `git log' and friends

1  2 
pretty.c
t/t6006-rev-list-format.sh

diff --combined pretty.c
index 7cb3a2af508bb5667cd74304f72b50766c749990,14c9568c54c8c4cfb73103ee066f39addff57def..742b48bbd615d8915a090a271b7446accbaa8412
+++ b/pretty.c
@@@ -775,13 -775,10 +775,13 @@@ static size_t format_commit_one(struct 
                }
                return 0;       /* unknown %g placeholder */
        case 'N':
 -              format_display_notes(commit->object.sha1, sb,
 -                          git_log_output_encoding ? git_log_output_encoding
 -                                                  : git_commit_encoding, 0);
 -              return 1;
 +              if (c->pretty_ctx->show_notes) {
 +                      format_display_notes(commit->object.sha1, sb,
 +                                  git_log_output_encoding ? git_log_output_encoding
 +                                                          : git_commit_encoding, 0);
 +                      return 1;
 +              }
 +              return 0;
        }
  
        /* For the rest we have to parse the commit header. */
        case 'e':       /* encoding */
                strbuf_add(sb, msg + c->encoding.off, c->encoding.len);
                return 1;
+       case 'B':       /* raw body */
+               /* message_off is always left at the initial newline */
+               strbuf_addstr(sb, msg + c->message_off + 1);
+               return 1;
        }
  
        /* Now we need to parse the commit message. */
@@@ -858,35 -859,6 +862,35 @@@ static size_t format_commit_item(struc
        return consumed + 1;
  }
  
 +static size_t userformat_want_item(struct strbuf *sb, const char *placeholder,
 +                                 void *context)
 +{
 +      struct userformat_want *w = context;
 +
 +      if (*placeholder == '+' || *placeholder == '-')
 +              placeholder++;
 +
 +      switch (*placeholder) {
 +      case 'N':
 +              w->notes = 1;
 +              break;
 +      }
 +      return 0;
 +}
 +
 +void userformat_find_requirements(const char *fmt, struct userformat_want *w)
 +{
 +      struct strbuf dummy = STRBUF_INIT;
 +
 +      if (!fmt) {
 +              if (!user_format)
 +                      return;
 +              fmt = user_format;
 +      }
 +      strbuf_expand(&dummy, user_format, userformat_want_item, w);
 +      strbuf_release(&dummy);
 +}
 +
  void format_commit_message(const struct commit *commit,
                           const char *format, struct strbuf *sb,
                           const struct pretty_print_context *pretty_ctx)
index a49b7c5722e6cb675f771c31e4eec87262388548,5d15f1836625d1a40b2575ad967a3053230f2408..9992be69f49c80bf1d21c9667a07d3a61aced39b
@@@ -101,6 -101,15 +101,15 @@@ commit 131a310eb913d107dd3c09a65d165117
  commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
  EOF
  
+ test_format raw-body %B <<'EOF'
+ commit 131a310eb913d107dd3c09a65d1651175898735d
+ changed foo
+ commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+ added foo
+ EOF
  test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
  commit 131a310eb913d107dd3c09a65d1651175898735d
  \e[31mfoo\e[32mbar\e[34mbaz\e[mxyzzy
@@@ -209,13 -218,4 +218,13 @@@ test_expect_success '%gd shortens ref n
        test_cmp expect.gd-short actual.gd-short
  '
  
 +test_expect_success 'oneline with empty message' '
 +      git commit -m "dummy" --allow-empty &&
 +      git commit -m "dummy" --allow-empty &&
 +      git filter-branch --msg-filter "sed -e s/dummy//" HEAD^^.. &&
 +      git rev-list --oneline HEAD >test.txt &&
 +      test $(git rev-list --oneline HEAD | wc -l) -eq 5 &&
 +      test $(git rev-list --oneline --graph HEAD | wc -l) -eq 5
 +'
 +
  test_done