summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5166810)
raw | patch | inline | side by side (parent: 5166810)
author | Michal Vitecek <fuf@mageo.cz> | |
Tue, 25 Sep 2007 14:38:46 +0000 (16:38 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 26 Sep 2007 07:40:47 +0000 (00:40 -0700) |
This changes the interporate() to replace entries with NULL values
by the empty string, and uses it to interpolate missing fields in
custom format output used in git-log and friends. It is most useful
to avoid <unknown> output from %b format for a commit log message
that lack any body text.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
by the empty string, and uses it to interpolate missing fields in
custom format output used in git-log and friends. It is most useful
to avoid <unknown> output from %b format for a commit log message
that lack any body text.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-rev-list.c | patch | blob | history | |
commit.c | patch | blob | history | |
interpolate.c | patch | blob | history | |
log-tree.c | patch | blob | history | |
t/t6006-rev-list-format.sh | patch | blob | history | |
t/t7500-commit.sh | patch | blob | history |
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 38946339999e4e136b898b8f314e27d22ec1decb..0b74eb35bcfae2dfe2145b33b1d56c0b90d7385f 100644 (file)
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
pretty_print_commit(revs.commit_format, commit, ~0,
&buf, &buflen,
revs.abbrev, NULL, NULL, revs.date_mode);
- printf("%s%c", buf, hdr_termination);
+ if (*buf)
+ printf("%s%c", buf, hdr_termination);
free(buf);
}
maybe_flush_or_die(stdout, "stdout");
diff --git a/commit.c b/commit.c
index 99f65cee0e7e30e833f850b5993aa8a5797ba889..c9a18180be5872acb9fc4e021b61492b71a0d9c9 100644 (file)
--- a/commit.c
+++ b/commit.c
}
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>");
do {
char *buf = *buf_p;
diff --git a/interpolate.c b/interpolate.c
index 00826778fc3d760a9b001423cd9c26e7972c126f..2f727cd05b0d071d9aa750b90fe3c16c12ccbe5e 100644 (file)
--- a/interpolate.c
+++ b/interpolate.c
/* 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 + 1 < reslen) {
/* Substitute. */
strncpy(dest, value, valuelen);
diff --git a/log-tree.c b/log-tree.c
index a6423718e76be34e62bc76dcf3c93b32e38aa152..79e3dee276e5b99b11c4f6986aaff74ad6ad7f5e 100644 (file)
--- a/log-tree.c
+++ b/log-tree.c
if (opt->show_log_size)
printf("log size %i\n", len);
- printf("%s%s%s", msgbuf, extra, sep);
+ if (*msgbuf)
+ printf("%s%s%s", msgbuf, extra, sep);
free(msgbuf);
}
index ad6d0b8c9da56e22b22d4fd97898f20101964e1f..1e4541afea07daa094895244f0e49803623cd1cd 100755 (executable)
test_format encoding %e <<'EOF'
commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
EOF
test_format subject %s <<'EOF'
test_format body %b <<'EOF'
commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
EOF
test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
commit f58db70b055c5718631e5c61528b28b12090cdea
iso8859-1
commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
EOF
test_format complex-subject %s <<'EOF'
include an iso8859 character: ¡bueno!
commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
EOF
test_done
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index f11ada8617d95e2c3840ed1ecbdb03745d1f6f2b..abbf54ba63693bbb3e839786bf97284c22912333 100755 (executable)
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
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' '
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