|  | @@ -0,0 +1,79 @@
 | 
	
		
			
				|  |  | +<?xml version="1.0" encoding="UTF-8"?>
 | 
	
		
			
				|  |  | +<xsl:stylesheet
 | 
	
		
			
				|  |  | +    version="1.0"
 | 
	
		
			
				|  |  | +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 | 
	
		
			
				|  |  | +>
 | 
	
		
			
				|  |  | + <xsl:param name="TMPDIR" select="'/tmp/darcs2git/'"/>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | + <xsl:output method="text"/>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | + <xsl:template match="/patches|/changelog">
 | 
	
		
			
				|  |  | +  <xsl:text>TMPDIR="</xsl:text>
 | 
	
		
			
				|  |  | +  <xsl:value-of select="$TMPDIR"/>
 | 
	
		
			
				|  |  | +  <xsl:text>"
 | 
	
		
			
				|  |  | +ulimit -c 0
 | 
	
		
			
				|  |  | +</xsl:text>
 | 
	
		
			
				|  |  | +  <xsl:apply-templates select="patch" />
 | 
	
		
			
				|  |  | +  <xsl:text>
 | 
	
		
			
				|  |  | +rm -rf $TMPDIR
 | 
	
		
			
				|  |  | +</xsl:text>
 | 
	
		
			
				|  |  | + </xsl:template>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | + <xsl:template match="patch">
 | 
	
		
			
				|  |  | +  <xsl:text>darcs pull --all --quiet --matches="hash </xsl:text>
 | 
	
		
			
				|  |  | +  <xsl:value-of select="@hash"/>
 | 
	
		
			
				|  |  | +  <xsl:text>" --posthook=': > '"${TMPDIR}darcs_files.txt"' ; for fnl in "$DARCS_FILES" ; do echo -n "$fnl" >> '"${TMPDIR}darcs_files.txt"' ; done' || exit 1
 | 
	
		
			
				|  |  | +sed -E -e 's%^\./%%' ${TMPDIR}darcs_files.txt | \
 | 
	
		
			
				|  |  | +sed -E -e $'s%(\\$|`|"|\\\\)%\\\\\\1%g' \
 | 
	
		
			
				|  |  | +    -e $'s%\'%\"\'\"%g' | \
 | 
	
		
			
				|  |  | +awk '{ printf " \"%s\"", $0 }' \
 | 
	
		
			
				|  |  | +> ${TMPDIR}darcs_files.args
 | 
	
		
			
				|  |  | +{ echo -n "git add --all" ; cat ${TMPDIR}darcs_files.args ; } > ${TMPDIR}git-add.sh
 | 
	
		
			
				|  |  | +sh -x ${TMPDIR}git-add.sh || exit 1
 | 
	
		
			
				|  |  | +cat > ${TMPDIR}git_commit.cmd << '-EOF-'
 | 
	
		
			
				|  |  | +git commit --allow-empty -m !:&#_</xsl:text>
 | 
	
		
			
				|  |  | +  <xsl:value-of select="name"/>
 | 
	
		
			
				|  |  | +  <xsl:text>!:&#_ -m !:&#_</xsl:text>
 | 
	
		
			
				|  |  | +  <xsl:value-of select="comment"/>
 | 
	
		
			
				|  |  | +  <xsl:text>!:&#_ --author=!:&#_</xsl:text>
 | 
	
		
			
				|  |  | +  <xsl:choose>
 | 
	
		
			
				|  |  | +   <xsl:when test="normalize-space(@author) = ''">
 | 
	
		
			
				|  |  | +    <xsl:text>darcs2git <></xsl:text>
 | 
	
		
			
				|  |  | +   </xsl:when>
 | 
	
		
			
				|  |  | +   <xsl:when test="not(contains(@author,'<'))">
 | 
	
		
			
				|  |  | +    <xsl:choose>
 | 
	
		
			
				|  |  | +     <xsl:when test="contains(@author,'@') and not(contains(substring-after(@author,'@'),'@'))">
 | 
	
		
			
				|  |  | +      <xsl:value-of select="normalize-space(substring-before(@author,'@'))"/>
 | 
	
		
			
				|  |  | +      <xsl:text> <</xsl:text>
 | 
	
		
			
				|  |  | +      <xsl:value-of select="normalize-space(@author)"/>
 | 
	
		
			
				|  |  | +      <xsl:text>></xsl:text>
 | 
	
		
			
				|  |  | +     </xsl:when>
 | 
	
		
			
				|  |  | +     <xsl:otherwise>
 | 
	
		
			
				|  |  | +      <xsl:value-of select="@author"/>
 | 
	
		
			
				|  |  | +      <xsl:text> <></xsl:text>
 | 
	
		
			
				|  |  | +     </xsl:otherwise>
 | 
	
		
			
				|  |  | +    </xsl:choose>
 | 
	
		
			
				|  |  | +   </xsl:when>
 | 
	
		
			
				|  |  | +   <xsl:when test="not(normalize-space(substring-before(@author,'<')))">
 | 
	
		
			
				|  |  | +    <xsl:text>darcs2git </xsl:text>
 | 
	
		
			
				|  |  | +    <xsl:value-of select="@author"/>
 | 
	
		
			
				|  |  | +   </xsl:when>
 | 
	
		
			
				|  |  | +   <xsl:otherwise>
 | 
	
		
			
				|  |  | +    <xsl:value-of select="@author"/>
 | 
	
		
			
				|  |  | +   </xsl:otherwise>
 | 
	
		
			
				|  |  | +  </xsl:choose>
 | 
	
		
			
				|  |  | +  <xsl:text>!:&#_ --date=!:&#_</xsl:text>
 | 
	
		
			
				|  |  | +  <xsl:value-of select="@local_date"/>
 | 
	
		
			
				|  |  | +  <xsl:text>!:&#_
 | 
	
		
			
				|  |  | +-EOF-
 | 
	
		
			
				|  |  | +sed -E -e $'s%(\\$|`|"|\\\\)%\\\\\\1%g' \
 | 
	
		
			
				|  |  | +    -e $'s%\'%\"\'\"%g' \
 | 
	
		
			
				|  |  | +    -e 's%!:&#_%"%g' ${TMPDIR}git_commit.cmd \
 | 
	
		
			
				|  |  | +    > ${TMPDIR}git-commit.sh
 | 
	
		
			
				|  |  | +truncate -s -1 ${TMPDIR}git-commit.sh
 | 
	
		
			
				|  |  | +cat ${TMPDIR}darcs_files.args >> ${TMPDIR}git-commit.sh
 | 
	
		
			
				|  |  | +sh -x ${TMPDIR}git-commit.sh || exit 1
 | 
	
		
			
				|  |  | +</xsl:text>
 | 
	
		
			
				|  |  | + </xsl:template>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +</xsl:stylesheet>
 |