Merge branch 'rt/commentchar-fmt-merge-msg'
authorJunio C Hamano <gitster@pobox.com>
Mon, 15 Apr 2013 19:40:56 +0000 (12:40 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Apr 2013 19:40:56 +0000 (12:40 -0700)
The new core.commentchar configuration was not applied to a few
places.

* rt/commentchar-fmt-merge-msg:
fmt-merge-msg: use core.commentchar in tag signatures completely
fmt-merge-msg: respect core.commentchar in people credits

1  2 
builtin/fmt-merge-msg.c
t/t6200-fmt-merge-msg.sh
diff --combined builtin/fmt-merge-msg.c
index 265a9253bfd7cacd730789212fdb5284fcd270ac,db76d9f3a8dd246ff2287c02ea15e7073730e8f6..1c040708696c8d6e81023b3261966fa751f14ad4
@@@ -287,10 -287,10 +287,10 @@@ static void credit_people(struct strbu
        const char *me;
  
        if (kind == 'a') {
-               label = "\n# By ";
+               label = "By";
                me = git_author_info(IDENT_NO_DATE);
        } else {
-               label = "\n# Via ";
+               label = "Via";
                me = git_committer_info(IDENT_NO_DATE);
        }
  
             (me = skip_prefix(me, them->items->string)) != NULL &&
             skip_prefix(me, " <")))
                return;
-       strbuf_addstr(out, label);
+       strbuf_addf(out, "\n%c %s ", comment_line_char, label);
        add_people_count(out, them);
  }
  
@@@ -492,7 -492,7 +492,7 @@@ static void fmt_merge_msg_sigs(struct s
  
                if (size == len)
                        ; /* merely annotated */
 -              else if (verify_signed_buffer(buf, len, buf + len, size - len, &sig)) {
 +              else if (verify_signed_buffer(buf, len, buf + len, size - len, &sig, NULL)) {
                        if (!sig.len)
                                strbuf_addstr(&sig, "gpg verification failed.\n");
                }
                } else {
                        if (tag_number == 2) {
                                struct strbuf tagline = STRBUF_INIT;
-                               strbuf_addf(&tagline, "\n# %s\n",
-                                           origins.items[first_tag].string);
+                               strbuf_addch(&tagline, '\n');
+                               strbuf_add_commented_lines(&tagline,
+                                               origins.items[first_tag].string,
+                                               strlen(origins.items[first_tag].string));
                                strbuf_insert(&tagbuf, 0, tagline.buf,
                                              tagline.len);
                                strbuf_release(&tagline);
                        }
-                       strbuf_addf(&tagbuf, "\n# %s\n",
-                                   origins.items[i].string);
+                       strbuf_addch(&tagbuf, '\n');
+                       strbuf_add_commented_lines(&tagbuf,
+                                       origins.items[i].string,
+                                       strlen(origins.items[i].string));
                        fmt_tag_signature(&tagbuf, &sig, buf, len);
                }
                strbuf_release(&sig);
diff --combined t/t6200-fmt-merge-msg.sh
index f73eceabfbcd0a763b8908a8d829894a5e36055b,84e10fde6fde69e69c24f959d529a5f946117352..e7e945db098de4ca491bea5dac36df34bcb13ebd
@@@ -112,8 -112,8 +112,8 @@@ test_expect_success '[merge] summary/lo
          Common #1
        EOF
  
 -      git config merge.log true &&
 -      test_might_fail git config --unset-all merge.summary &&
 +      test_config merge.log true &&
 +      test_unconfig merge.summary &&
  
        git checkout master &&
        test_tick &&
  
        git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
  
 -      test_might_fail git config --unset-all merge.log &&
 -      git config merge.summary true &&
 +      test_unconfig merge.log &&
 +      test_config merge.summary true &&
  
        git checkout master &&
        test_tick &&
        test_cmp expected actual2
  '
  
 -test_expect_success 'setup: clear [merge] configuration' '
 -      test_might_fail git config --unset-all merge.log &&
 -      test_might_fail git config --unset-all merge.summary
 -'
 -
  test_expect_success 'setup FETCH_HEAD' '
        git checkout master &&
        test_tick &&
@@@ -175,6 -180,24 +175,24 @@@ test_expect_success 'merge.log=5 shows 
        test_cmp expected actual
  '
  
+ test_expect_success '--log=5 with custom comment character' '
+       cat >expected <<-EOF &&
+       Merge branch ${apos}left${apos}
+       / By Another Author (3) and A U Thor (2)
+       / Via Another Committer
+       * left:
+         Left #5
+         Left #4
+         Left #3
+         Common #2
+         Common #1
+       EOF
+       git -c core.commentchar="/" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
+       test_cmp expected actual
+ '
  test_expect_success 'merge.log=0 disables shortlog' '
        echo "Merge branch ${apos}left${apos}" >expected
        git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&
@@@ -243,14 -266,14 +261,14 @@@ test_expect_success 'fmt-merge-msg -m' 
          Common #1
        EOF
  
 -      test_might_fail git config --unset merge.log &&
 -      test_might_fail git config --unset merge.summary &&
 +      test_unconfig merge.log &&
 +      test_unconfig merge.summary &&
        git checkout master &&
        git fetch "$(pwd)" left &&
        git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
        git fmt-merge-msg --log -m "Sync with left" \
                                        <.git/FETCH_HEAD >actual.log &&
 -      git config merge.log true &&
 +      test_config merge.log true &&
        git fmt-merge-msg -m "Sync with left" \
                                        <.git/FETCH_HEAD >actual.log-config &&
        git fmt-merge-msg --no-log -m "Sync with left" \
@@@ -285,29 -308,29 +303,29 @@@ test_expect_success 'setup: expected sh
  '
  
  test_expect_success 'shortlog for two branches' '
 -      git config merge.log true &&
 -      test_might_fail git config --unset-all merge.summary &&
 +      test_config merge.log true &&
 +      test_unconfig merge.summary &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
        git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
  
 -      test_might_fail git config --unset-all merge.log &&
 -      git config merge.summary true &&
 +      test_unconfig merge.log &&
 +      test_config merge.summary true &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
        git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
  
 -      git config merge.log yes &&
 -      test_might_fail git config --unset-all merge.summary &&
 +      test_config merge.log yes &&
 +      test_unconfig merge.summary &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
        git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
  
 -      test_might_fail git config --unset-all merge.log &&
 -      git config merge.summary yes &&
 +      test_unconfig merge.log &&
 +      test_config merge.summary yes &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
  '
  
  test_expect_success 'merge-msg -F' '
 -      test_might_fail git config --unset-all merge.log &&
 -      git config merge.summary yes &&
 +      test_unconfig merge.log &&
 +      test_config merge.summary yes &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
  '
  
  test_expect_success 'merge-msg -F in subdirectory' '
 -      test_might_fail git config --unset-all merge.log &&
 -      git config merge.summary yes &&
 +      test_unconfig merge.log &&
 +      test_config merge.summary yes &&
        git checkout master &&
        test_tick &&
        git fetch . left right &&
  '
  
  test_expect_success 'merge-msg with nothing to merge' '
 -      test_might_fail git config --unset-all merge.log &&
 -      git config merge.summary yes &&
 +      test_unconfig merge.log &&
 +      test_config merge.summary yes &&
  
        >empty &&
  
@@@ -371,8 -394,8 +389,8 @@@ test_expect_success 'merge-msg tag' 
          Common #1
        EOF
  
 -      test_might_fail git config --unset-all merge.log &&
 -      git config merge.summary yes &&
 +      test_unconfig merge.log &&
 +      test_config merge.summary yes &&
  
        git checkout master &&
        test_tick &&
@@@ -401,8 -424,8 +419,8 @@@ test_expect_success 'merge-msg two tags
          Common #1
        EOF
  
 -      test_might_fail git config --unset-all merge.log &&
 -      git config merge.summary yes &&
 +      test_unconfig merge.log &&
 +      test_config merge.summary yes &&
  
        git checkout master &&
        test_tick &&
@@@ -431,8 -454,8 +449,8 @@@ test_expect_success 'merge-msg tag and 
          Common #1
        EOF
  
 -      test_might_fail git config --unset-all merge.log &&
 -      git config merge.summary yes &&
 +      test_unconfig merge.log &&
 +      test_config merge.summary yes &&
  
        git checkout master &&
        test_tick &&
@@@ -459,8 -482,6 +477,8 @@@ test_expect_success 'merge-msg lots of 
                echo "  ..."
        } >expected &&
  
 +      test_config merge.summary yes &&
 +
        git checkout master &&
        test_tick &&
        git fetch . long &&
        test_cmp expected actual
  '
  
 +test_expect_success 'merge-msg with "merging" an annotated tag' '
 +      test_config merge.log true &&
 +
 +      git checkout master^0 &&
 +      git commit --allow-empty -m "One step ahead" &&
 +      git tag -a -m "An annotated one" annote HEAD &&
 +
 +      git checkout master &&
 +      git fetch . annote &&
 +
 +      git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 +      {
 +              cat <<-\EOF
 +              Merge tag '\''annote'\''
 +
 +              An annotated one
 +
 +              * tag '\''annote'\'':
 +                One step ahead
 +              EOF
 +      } >expected &&
 +      test_cmp expected actual &&
 +
 +      test_when_finished "git reset --hard" &&
 +      annote=$(git rev-parse annote) &&
 +      git merge --no-commit $annote &&
 +      {
 +              cat <<-EOF
 +              Merge tag '\''$annote'\''
 +
 +              An annotated one
 +
 +              * tag '\''$annote'\'':
 +                One step ahead
 +              EOF
 +      } >expected &&
 +      test_cmp expected .git/MERGE_MSG
 +'
 +
  test_done