Hello,
I have added a new placeholder '%cm' for a full commit message. I made
it because I want to use my own pretty format which currently only
allows '%s' for subject and '%b' for body. But '%b' is substituted with
<undefined> if the body is "missing" which I obviously don't like :)Thanks for consideration,
Michal
--
fuf (fuf@mageo.cz)
Hi,
You mean the raw message, including the headers? Why not use "%r" for
Then you should fix %b not to show "<undefined>".
And please adher to the tips in Documentation/SubmittingPatches.
Thank you,
Dscho-
No, sorry for the incorrect term. I meant the whole commit message
I'll do it if it is okay. Shall I do the same for the other
Will do, sorry about the attachment - still learning :)
Thank you,
Michal
--
fuf (fuf@mageo.cz)
-
Hi,
No problem. Thanks for contributing!
Ciao,
Dscho-
I think it's no longer needed if instead of "<undefined>" only "" will
Here comes the big patch :)
From 2e4ba4e73bbcd19558039dd85fe45c7bbe7fd1c4 Mon Sep 17 00:00:00 2001
From: Michal Vitecek <fuf@mageo.cz>
Date: Fri, 21 Sep 2007 14:40:37 +0200
Subject: [PATCH] Use "" instead of "<unknown>" for placeholders---
commit.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)diff --git a/commit.c b/commit.c
index 99f65ce..7e90bc1 100644
--- a/commit.c
+++ b/commit.c
@@ -919,7 +919,7 @@ long format_commit_message(const struct commit *commit, const void *format,
table[IBODY].value = xstrdup(msg + i);
for (i = 0; i < ARRAY_SIZE(table); i++)
if (!table[i].value)
- interp_set_entry(table, i, "<unknown>");
+ interp_set_entry(table, i, "");do {
char *buf = *buf_p;
--
1.5.3.1--
fuf (fuf@mageo.cz)
-
Michal Vitecek <fuf@mageo.cz> writes:
Now, this breaks t6006 which needs this patch.
Looking at this patch, I am not sure if your change is really a
desirable one --- shouldn't it be removing the line itself, not
just <unknown> token?---
t/t6006-rev-list-format.sh | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index ad6d0b8..2be323c 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -79,9 +79,9 @@ EOFtest_format encoding %e <<'EOF'
commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
+
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
+
EOFtest_format subject %s <<'EOF'
@@ -93,9 +93,9 @@ EOFtest_format body %b <<'EOF'
commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
+
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
+
EOFtest_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
@@ -121,9 +121,9 @@ test_format complex-encoding %e <<'EOF'
commit f58db70b055c5718631e5c61528b28b12090cdea
iso8859-1
commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
+
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
+
EOFtest_format complex-subject %s <<'EOF'
@@ -142,9 +142,9 @@ and it will be encoded in iso8859-1. We should therefore
include an iso8859 character: 臓bueno!commit 131a310eb913d107dd3c09a65d1651175898735d
-<unknown>
+
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-<unknown>
+
EOFtest_done
-
Oops - I'm sorry about that. I ran the test suite (1.5.3.1) but it
failed in 2 tests before the patch and in 2 tests after it so IThis sounds as the best solution. I'll look into it. Thanks for your time.
--
fuf (fuf@mageo.cz)
-
Hello again,
Here comes the patch. I hope it will be ok this time :) Thanks.
Don't use "<unknown>" for unknown values of placeholders and suppress
printing of empty user formats.---
builtin-rev-list.c | 3 ++-
commit.c | 3 ---
interpolate.c | 6 +++++-
log-tree.c | 10 ++++++----
t/t6006-rev-list-format.sh | 8 --------
t/t7500-commit.sh | 4 ++--
6 files changed, 15 insertions(+), 19 deletions(-)diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 3894633..1de981d 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -85,7 +85,8 @@ static void show_commit(struct commit *commit)
pretty_print_commit(revs.commit_format, commit, ~0,
&buf, &buflen,
revs.abbrev, NULL, NULL, revs.date_mode);
- printf("%s%c", buf, hdr_termination);
+ if (strlen(buf))
+ printf("%s%c", buf, hdr_termination);
free(buf);
}
maybe_flush_or_die(stdout, "stdout");
diff --git a/commit.c b/commit.c
index 99f65ce..c9a1818 100644
--- a/commit.c
+++ b/commit.c
@@ -917,9 +917,6 @@ long format_commit_message(const struct commit *commit, const void *format,
}
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 0082677..58fd055 100644
--- a/interpolate.c
+++ b/interpolate.c
@@ -76,8 +76,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 == NULL) {
+ src += namelen;
+ continue;
+ }+ valuelen = strlen(value);
if (newl...
Hi,
Please move the discussion which should not be in the commit message
We use tabs for indentation, not spaces.
Also, instead of the expensive "strlen(buf)", you rather want to check "if
Again, "if (*msgbuf)" is way more efficient.
Ciao,
Dscho-
Hi,
What about this comment?
Ciao,
Dscho-
Hi,
---
Thanks for the notes - here comes the patch with the above fixes.
builtin-rev-list.c | 3 ++-
commit.c | 3 ---
interpolate.c | 6 +++++-
log-tree.c | 10 ++++++----
t/t6006-rev-list-format.sh | 8 --------
t/t7500-commit.sh | 4 ++--
6 files changed, 15 insertions(+), 19 deletions(-)diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 3894633..0b74eb3 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -85,7 +85,8 @@ static void show_commit(struct commit *commit)
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 99f65ce..c9a1818 100644
--- a/commit.c
+++ b/commit.c
@@ -917,9 +917,6 @@ long format_commit_message(const struct commit *commit, const void *format,
}
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 0082677..2f727cd 100644
--- a/interpolate.c
+++ b/interpolate.c
@@ -76,8 +76,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 + 1 < reslen) {
/* Substitute. */
strncpy(dest, value, valuelen);
diff --git a/log-tree.c b/log-tree.c
index a642371..79502f4 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -175,14 +175,15 @@ void show_log(struct rev_info *opt, const char *sep)
...
Hi,
Thanks. I missed that one. My comment would have been exactly the same.
Ciao,
Dscho
-
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Andi Kleen | [PATCH x86] [0/16] Various i386/x86-64 changes |
| Vladislav Bolkhovitin | Re: Integration of SCST in the mainstream Linux kernel |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
git: | |
| Gerrit Renker | [PATCH 0/37] dccp: Feature negotiation - last call for comments |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Natalie Protasevich | [BUG] New Kernel Bugs |
| Arjan van de Ven | Re: [GIT]: Networking |
