* git am and the wrong chunk of --- @ 2012-08-10 0:13 H. Peter Anvin 2012-08-10 1:26 ` Junio C Hamano 2012-08-10 10:36 ` Jeff King 0 siblings, 2 replies; 8+ messages in thread From: H. Peter Anvin @ 2012-08-10 0:13 UTC (permalink / raw) To: Git Mailing List Hello, I have some contributors who consistently put their commentary *before* the "---" line rather than *after* it, presumably with the notion that it is some kind of "cover text". This messes with "git am", and so I end up having to edit those posts manually. I have tried git am --scissors and it doesn't seem to solve the problem. Is there any other option which can be used to automatically process such a patch? -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git am and the wrong chunk of --- 2012-08-10 0:13 git am and the wrong chunk of --- H. Peter Anvin @ 2012-08-10 1:26 ` Junio C Hamano 2012-08-10 10:36 ` Jeff King 1 sibling, 0 replies; 8+ messages in thread From: Junio C Hamano @ 2012-08-10 1:26 UTC (permalink / raw) To: H. Peter Anvin; +Cc: Git Mailing List "H. Peter Anvin" <hpa@zytor.com> writes: > Hello, > > I have some contributors who consistently put their commentary > *before* the "---" line rather than *after* it, presumably with the > notion that it is some kind of "cover text". This messes with "git > am", and so I end up having to edit those posts manually. > > I have tried git am --scissors and it doesn't seem to solve the problem. > > Is there any other option which can be used to automatically process > such a patch? I hate to be the one who is telling you this, but if the submitter cannot be trained to write supporting material after "---" as the convention across git using projects suggest him to do, it is likely that he didn't write supporting material before the scissors, or did not resist the temptation to deviate from the accepted shape of the scissors (e.g. "-- >8 --") just to be creative. For that matter, I would be mildly surprised if the material in the middle is usable as is as an acceptable log message from such a submitter X-<. So in short, no, --scissors (or -c in short) is not any more magical than the traditional "---". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git am and the wrong chunk of --- 2012-08-10 0:13 git am and the wrong chunk of --- H. Peter Anvin 2012-08-10 1:26 ` Junio C Hamano @ 2012-08-10 10:36 ` Jeff King 2012-08-10 11:00 ` Andreas Ericsson 2012-08-10 14:46 ` Junio C Hamano 1 sibling, 2 replies; 8+ messages in thread From: Jeff King @ 2012-08-10 10:36 UTC (permalink / raw) To: H. Peter Anvin; +Cc: Git Mailing List On Thu, Aug 09, 2012 at 05:13:51PM -0700, H. Peter Anvin wrote: > I have some contributors who consistently put their commentary > *before* the "---" line rather than *after* it, presumably with the > notion that it is some kind of "cover text". This messes with "git > am", and so I end up having to edit those posts manually. > > I have tried git am --scissors and it doesn't seem to solve the problem. > > Is there any other option which can be used to automatically process > such a patch? If I understand your issue, somebody is writing: From: them To: you Date: ... Subject: [PATCH] subject line commit message body .... some cover letter material that should go below the "---" --- [diffstat + diff] How do you know when the commit message body ends, and the cover letter begins? We already have two machine-readable formats for separating the two ("---" after the commit message, and "-- >8 --" scissors before). Is there some machine-readable hint? Is it always the paragraph before the "---"? Chopping that off unconditionally seems like a dangerous heuristic. -Peff ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git am and the wrong chunk of --- 2012-08-10 10:36 ` Jeff King @ 2012-08-10 11:00 ` Andreas Ericsson 2012-08-10 14:46 ` Junio C Hamano 1 sibling, 0 replies; 8+ messages in thread From: Andreas Ericsson @ 2012-08-10 11:00 UTC (permalink / raw) To: Jeff King; +Cc: H. Peter Anvin, Git Mailing List On 08/10/2012 12:36 PM, Jeff King wrote: > On Thu, Aug 09, 2012 at 05:13:51PM -0700, H. Peter Anvin wrote: > >> I have some contributors who consistently put their commentary >> *before* the "---" line rather than *after* it, presumably with the >> notion that it is some kind of "cover text". This messes with "git >> am", and so I end up having to edit those posts manually. >> >> I have tried git am --scissors and it doesn't seem to solve the problem. >> >> Is there any other option which can be used to automatically process >> such a patch? > > If I understand your issue, somebody is writing: > > > From: them > To: you > Date: ... > Subject: [PATCH] subject line > > commit message body > .... > > some cover letter material that should go below the "---" > --- > [diffstat + diff] > > > How do you know when the commit message body ends, and the cover letter > begins? We already have two machine-readable formats for separating the > two ("---" after the commit message, and "-- >8 --" scissors before). Is > there some machine-readable hint? Is it always the paragraph before the > "---"? Chopping that off unconditionally seems like a dangerous > heuristic. > End of SOB lines might be a good cutoff, if they're present. I've never seen anyone put commit message text below them anyway. -- Andreas Ericsson andreas.ericsson@op5.se OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231 Considering the successes of the wars on alcohol, poverty, drugs and terror, I think we should give some serious thought to declaring war on peace. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git am and the wrong chunk of --- 2012-08-10 10:36 ` Jeff King 2012-08-10 11:00 ` Andreas Ericsson @ 2012-08-10 14:46 ` Junio C Hamano 2012-08-10 14:48 ` H. Peter Anvin 1 sibling, 1 reply; 8+ messages in thread From: Junio C Hamano @ 2012-08-10 14:46 UTC (permalink / raw) To: Jeff King; +Cc: H. Peter Anvin, Git Mailing List Jeff King <peff@peff.net> writes: > If I understand your issue, somebody is writing: > > > From: them > To: you > Date: ... > Subject: [PATCH] subject line > > commit message body > .... > > some cover letter material that should go below the "---" > --- > [diffstat + diff] > > How do you know when the commit message body ends, and the cover letter > begins? We already have two machine-readable formats for separating the > two ("---" after the commit message, and "-- >8 --" scissors before). Is > there some machine-readable hint? Is it always the paragraph before the > "---"? Chopping that off unconditionally seems like a dangerous > heuristic. Or it could be like this: ... Subject: [PATCH] patch title Heya, I was walking my dog when I found a solution to this problem the other day. Here it is. commit message body S-o-b: ... --- And I agree that clever heuristics are dangerous. We need to draw a line somewhere anyway, and the line should be at the place that is easily understandable to people. That means mechanically parseable and easy to follow convention to use markers e.g. "---". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git am and the wrong chunk of --- 2012-08-10 14:46 ` Junio C Hamano @ 2012-08-10 14:48 ` H. Peter Anvin 2012-08-10 16:15 ` Junio C Hamano 0 siblings, 1 reply; 8+ messages in thread From: H. Peter Anvin @ 2012-08-10 14:48 UTC (permalink / raw) To: Junio C Hamano, Jeff King; +Cc: Git Mailing List The users I am referring to generally have a --- line, rather than a scissor, between the cover text and commit. Also, there is (almost) always a From: line and subject at the top of the patch proper. Junio C Hamano <gitster@pobox.com> wrote: >Jeff King <peff@peff.net> writes: > >> If I understand your issue, somebody is writing: >> >> >> From: them >> To: you >> Date: ... >> Subject: [PATCH] subject line >> >> commit message body >> .... >> >> some cover letter material that should go below the "---" >> --- >> [diffstat + diff] >> >> How do you know when the commit message body ends, and the cover >letter >> begins? We already have two machine-readable formats for separating >the >> two ("---" after the commit message, and "-- >8 --" scissors before). >Is >> there some machine-readable hint? Is it always the paragraph before >the >> "---"? Chopping that off unconditionally seems like a dangerous >> heuristic. > >Or it could be like this: > > ... > Subject: [PATCH] patch title > > Heya, > > I was walking my dog when I found a solution to this > problem the other day. Here it is. > > commit message body > > S-o-b: ... > --- > >And I agree that clever heuristics are dangerous. We need to draw a >line somewhere anyway, and the line should be at the place that is >easily understandable to people. That means mechanically parseable >and easy to follow convention to use markers e.g. "---". -- Sent from my mobile phone. Please excuse brevity and lack of formatting. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git am and the wrong chunk of --- 2012-08-10 14:48 ` H. Peter Anvin @ 2012-08-10 16:15 ` Junio C Hamano 2012-08-10 16:39 ` H. Peter Anvin 0 siblings, 1 reply; 8+ messages in thread From: Junio C Hamano @ 2012-08-10 16:15 UTC (permalink / raw) To: H. Peter Anvin; +Cc: Jeff King, Git Mailing List "H. Peter Anvin" <hpa@zytor.com> writes: > The users I am referring to generally have a --- line, rather than > a scissor, between the cover text and commit. Also, there is > (almost) always a From: line and subject at the top of the patch > proper. Oh, so it is more like this? From: author name <author@address.xz> Date: author date Subject: patch title Heya, I was walking my dog when I found a solution to this problem the other day. Here it is. --- >From 755e8b3f35e3991a735a6be740eda4567d45a741 Mon Sep 17 00:00:00 2001 From: author name <author@address.xz> Date: random date we do not care Subject: patch title commit message body --- We could teach "am -c" to recognize the format-patch file magic "^[>]From [0-9a-f]{40} Mon Sep 17 00:00:00 2001" as another form of accepted scissors, I guess. Something like the attached (untested) patch, perhaps. But I am fairly negative on it. Where would it end? After all, the top "---" is not something our tools are generating, but is manually typed by the users. I do not think it is unreasonable to expect that they are capable and intelligent enough to guess that "---" is _not_ the way to say "cut here and what follows are the log message", when "---" is already the way to say "cut here, and what we saw up to this point is the log message". builtin/mailinfo.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index eaf9e15..62ea09d 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -730,6 +730,22 @@ static inline int patchbreak(const struct strbuf *line) return 0; } +static int is_format_patch_magic(const struct strbuf *line) +{ + const char *buf = line->buf; + size_t len = line->len; + + if (len && *buf == '>') { + buf++; + len--; + } + if (len < 70) + return 0; + return (!memcmp(buf, "From ", 5) && + strspn(buf + 5, "0123456789abcdef") == 40 && + !memcmp(buf + 46, "Mon Sep 17 00:00:00 2001", 24)); +} + static int is_scissors_line(const struct strbuf *line) { size_t i, len = line->len; @@ -807,7 +823,7 @@ static int handle_commit_msg(struct strbuf *line) if (metainfo_charset) convert_to_utf8(line, charset.buf); - if (use_scissors && is_scissors_line(line)) { + if (use_scissors && (is_scissors_line(line) || is_format_patch_magic(line))) { int i; if (fseek(cmitmsg, 0L, SEEK_SET)) die_errno("Could not rewind output message file"); ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: git am and the wrong chunk of --- 2012-08-10 16:15 ` Junio C Hamano @ 2012-08-10 16:39 ` H. Peter Anvin 0 siblings, 0 replies; 8+ messages in thread From: H. Peter Anvin @ 2012-08-10 16:39 UTC (permalink / raw) To: Junio C Hamano; +Cc: Jeff King, Git Mailing List On 08/10/2012 09:15 AM, Junio C Hamano wrote: > "H. Peter Anvin" <hpa@zytor.com> writes: > >> The users I am referring to generally have a --- line, rather than >> a scissor, between the cover text and commit. Also, there is >> (almost) always a From: line and subject at the top of the patch >> proper. > > Oh, so it is more like this? > > From: author name <author@address.xz> > Date: author date > Subject: patch title > > Heya, > > I was walking my dog when I found a solution to this > problem the other day. Here it is. > > --- > >From 755e8b3f35e3991a735a6be740eda4567d45a741 Mon Sep 17 00:00:00 2001 > From: author name <author@address.xz> > Date: random date we do not care > Subject: patch title > > commit message body > > --- > That is exactly what I see, except usually with the mbox header. However, it makes sense to me to treat From: as a scissor (we can then ignore the preceding --- completely). -hpa ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-08-10 16:40 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-08-10 0:13 git am and the wrong chunk of --- H. Peter Anvin 2012-08-10 1:26 ` Junio C Hamano 2012-08-10 10:36 ` Jeff King 2012-08-10 11:00 ` Andreas Ericsson 2012-08-10 14:46 ` Junio C Hamano 2012-08-10 14:48 ` H. Peter Anvin 2012-08-10 16:15 ` Junio C Hamano 2012-08-10 16:39 ` H. Peter Anvin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).