Browse Source

Merge branch 'mv/unknown'

* mv/unknown:
  Don't use "<unknown>" for placeholders and suppress printing of empty user formats.
maint
Junio C Hamano 18 years ago
parent
commit
cc61ae82ec
  1. 3
      builtin-rev-list.c
  2. 3
      commit.c
  3. 6
      interpolate.c
  4. 3
      log-tree.c
  5. 8
      t/t6006-rev-list-format.sh
  6. 4
      t/t7500-commit.sh

3
builtin-rev-list.c

@ -84,7 +84,8 @@ static void show_commit(struct commit *commit) @@ -84,7 +84,8 @@ static void show_commit(struct commit *commit)
strbuf_init(&buf, 0);
pretty_print_commit(revs.commit_format, commit,
&buf, revs.abbrev, NULL, NULL, revs.date_mode);
printf("%s%c", buf.buf, hdr_termination);
if (buf.len)
printf("%s%c", buf.buf, hdr_termination);
strbuf_release(&buf);
}
maybe_flush_or_die(stdout, "stdout");

3
commit.c

@ -876,9 +876,6 @@ void format_commit_message(const struct commit *commit, @@ -876,9 +876,6 @@ void format_commit_message(const struct commit *commit,
}
if (msg[i])
table[IBODY].value = xstrdup(msg + i);
for (i = 0; i < ARRAY_SIZE(table); i++)
if (!table[i].value)
interp_set_entry(table, i, "<unknown>");

len = interpolate(sb->buf + sb->len, strbuf_avail(sb),
format, table, ARRAY_SIZE(table));

6
interpolate.c

@ -73,8 +73,12 @@ unsigned long interpolate(char *result, unsigned long reslen, @@ -73,8 +73,12 @@ unsigned long interpolate(char *result, unsigned long reslen,
/* Check for valid interpolation. */
if (i < ninterps) {
value = interps[i].value;
valuelen = strlen(value);
if (!value) {
src += namelen;
continue;
}

valuelen = strlen(value);
if (newlen + valuelen < reslen) {
/* Substitute. */
memcpy(dest, value, valuelen);

3
log-tree.c

@ -280,7 +280,8 @@ void show_log(struct rev_info *opt, const char *sep) @@ -280,7 +280,8 @@ void show_log(struct rev_info *opt, const char *sep)
if (opt->show_log_size)
printf("log size %i\n", (int)msgbuf.len);

printf("%s%s%s", msgbuf.buf, extra, sep);
if (msgbuf.len)
printf("%s%s%s", msgbuf.buf, extra, sep);
strbuf_release(&msgbuf);
}


8
t/t6006-rev-list-format.sh

@ -79,9 +79,7 @@ EOF @@ -79,9 +79,7 @@ EOF

test_format encoding %e <<'EOF'
commit 131a310eb913d107dd3c09a65d1651175898735d
<unknown>
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
<unknown>
EOF

test_format subject %s <<'EOF'
@ -93,9 +91,7 @@ EOF @@ -93,9 +91,7 @@ EOF

test_format body %b <<'EOF'
commit 131a310eb913d107dd3c09a65d1651175898735d
<unknown>
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
<unknown>
EOF

test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
@ -121,9 +117,7 @@ test_format complex-encoding %e <<'EOF' @@ -121,9 +117,7 @@ test_format complex-encoding %e <<'EOF'
commit f58db70b055c5718631e5c61528b28b12090cdea
iso8859-1
commit 131a310eb913d107dd3c09a65d1651175898735d
<unknown>
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
<unknown>
EOF

test_format complex-subject %s <<'EOF'
@ -142,9 +136,7 @@ and it will be encoded in iso8859-1. We should therefore @@ -142,9 +136,7 @@ and it will be encoded in iso8859-1. We should therefore
include an iso8859 character: ¡bueno!

commit 131a310eb913d107dd3c09a65d1651175898735d
<unknown>
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
<unknown>
EOF

test_done

4
t/t7500-commit.sh

@ -81,7 +81,7 @@ test_expect_success 'explicit commit message should override template' ' @@ -81,7 +81,7 @@ test_expect_success 'explicit commit message should override template' '
git add foo &&
GIT_EDITOR=../t7500/add-content git commit --template "$TEMPLATE" \
-m "command line msg" &&
commit_msg_is "command line msg<unknown>"
commit_msg_is "command line msg"
'

test_expect_success 'commit message from file should override template' '
@ -90,7 +90,7 @@ test_expect_success 'commit message from file should override template' ' @@ -90,7 +90,7 @@ test_expect_success 'commit message from file should override template' '
echo "standard input msg" |
GIT_EDITOR=../t7500/add-content git commit \
--template "$TEMPLATE" --file - &&
commit_msg_is "standard input msg<unknown>"
commit_msg_is "standard input msg"
'

test_done

Loading…
Cancel
Save