patch: match 'diff --git a/' instead of 'diff --git'
This reduces the likelihood of a traceback when trying to email a
patch that happens to have 'diff --git' at the beginning of a line
in the description, as this patch did:
http://markmail.org/message/wxpgowxd7ucxygwe
--- a/mercurial/patch.py Thu Mar 21 18:16:49 2013 +0100
+++ b/mercurial/patch.py Fri Mar 22 17:27:06 2013 -0500
@@ -314,7 +314,7 @@
gitpatches = []
for line in lr:
line = line.rstrip(' \r\n')
- if line.startswith('diff --git'):
+ if line.startswith('diff --git a/'):
m = gitre.match(line)
if m:
if gp:
@@ -1211,7 +1211,7 @@
emitfile = False
yield 'file', (afile, bfile, h, gp and gp.copy() or None)
yield 'hunk', h
- elif x.startswith('diff --git'):
+ elif x.startswith('diff --git a/'):
m = gitre.match(x.rstrip(' \r\n'))
if not m:
continue
@@ -1815,7 +1815,7 @@
addresult()
# set numbers to 0 anyway when starting new file
adds, removes, isbinary = 0, 0, False
- if line.startswith('diff --git'):
+ if line.startswith('diff --git a/'):
filename = gitre.search(line).group(1)
elif line.startswith('diff -r'):
# format: "diff -r ... -r ... filename"