git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Documentation/Makefile: fix interrupted builds of user-manual.xml
@ 2010-04-22  1:18 Jonathan Nieder
  2010-04-22  6:13 ` Chris Johnsen
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Nieder @ 2010-04-22  1:18 UTC (permalink / raw)
  To: git; +Cc: Chris Johnsen, Junio C Hamano

Unlike gcc, asciidoc does not atomically write its output file or
delete it when interrupted.  If it is interrupted in the middle of
writing an XML file, the result will be truncated input for xsltproc.

	XSLTPROC user-manual.html
	user-manual.xml:998: parser error : Premature end of data in t

Take care of this case by writing to a temporary and renaming it when
finished.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Based on a true story.

 Documentation/Makefile |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 8a8a395..04f69cf 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -264,7 +264,9 @@ manpage-base-url.xsl: manpage-base-url.xsl.in
 	mv $@+ $@
 
 user-manual.xml: user-manual.txt user-manual.conf
-	$(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book $<
+	$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
+	$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d book -o $@+ $< && \
+	mv $@+ $@
 
 technical/api-index.txt: technical/api-index-skel.txt \
 	technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
@@ -278,7 +280,9 @@ XSLT = docbook.xsl
 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
 
 user-manual.html: user-manual.xml
-	$(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
+	$(QUIET_XSLTPROC)$(RM) $@+ $@ && \
+	xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
+	mv $@+ $@
 
 git.info: user-manual.texi
 	$(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
-- 
1.7.1.rc1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Documentation/Makefile: fix interrupted builds of user-manual.xml
  2010-04-22  1:18 [PATCH] Documentation/Makefile: fix interrupted builds of user-manual.xml Jonathan Nieder
@ 2010-04-22  6:13 ` Chris Johnsen
  2010-04-22 10:24   ` Jonathan Nieder
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Johnsen @ 2010-04-22  6:13 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Junio C Hamano

(Resend, including the all original recipients. Sorry for the dupe,  
Jonathan.)

On 2010 Apr 21, at 20:18, Jonathan Nieder wrote:
> Unlike gcc, asciidoc does not atomically write its output file or
> delete it when interrupted.  If it is interrupted in the middle of
> writing an XML file, the result will be truncated input for xsltproc.
>
> 	XSLTPROC user-manual.html
> 	user-manual.xml:998: parser error : Premature end of data in t
>
> Take care of this case by writing to a temporary and renaming it when
> finished.
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> Based on a true story.
>

For what it is worth, the changes seem reasonable to me. There may be  
a few other places that could use the same treatment, though maybe  
not all the other documentation tools suffer to the same degree as  
asciidoc.


> @@ -278,7 +280,9 @@ XSLT = docbook.xsl
>  XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
>
>  user-manual.html: user-manual.xml
> -	$(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
> +	$(QUIET_XSLTPROC)$(RM) $@+ $@ && \
> +	xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
> +	mv $@+ $@
>
>  git.info: user-manual.texi
>  	$(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
>

I suppose it is obvious enough what is going on in this in this  
second hunk, but there is no mention of this change in the commit  
message. Is this hunk due to a similar problem with xsltproc? Or  
maybe this is just "defensive coding"?

-- 
Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Documentation/Makefile: fix interrupted builds of user-manual.xml
  2010-04-22  6:13 ` Chris Johnsen
@ 2010-04-22 10:24   ` Jonathan Nieder
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Nieder @ 2010-04-22 10:24 UTC (permalink / raw)
  To: Chris Johnsen; +Cc: git, Junio C Hamano

Chris Johnsen wrote:
> On 2010 Apr 21, at 20:18, Jonathan Nieder wrote:

>> user-manual.html: user-manual.xml
>> -	$(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
>> +	$(QUIET_XSLTPROC)$(RM) $@+ $@ && \
>> +	xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
>> +	mv $@+ $@
>>
[...]
> I suppose it is obvious enough what is going on in this in this
> second hunk, but there is no mention of this change in the commit
> message. Is this hunk due to a similar problem with xsltproc? Or
> maybe this is just "defensive coding"?

xsltproc indeed has the same problem, as I learned while testing
the first hunk.  Thanks for asking.

Sorry for the incomplete explanation before.
Jonathan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-22 10:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-22  1:18 [PATCH] Documentation/Makefile: fix interrupted builds of user-manual.xml Jonathan Nieder
2010-04-22  6:13 ` Chris Johnsen
2010-04-22 10:24   ` Jonathan Nieder

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).