##// END OF EJS Templates
Don't generate git diff header for empty diffs
Brendan Cully -
r3329:319358e6 default
parent child Browse files
Show More
@@ -467,6 +467,7 b' def diff(repo, node1=None, node2=None, f'
467 to = None
467 to = None
468 tn = None
468 tn = None
469 dodiff = True
469 dodiff = True
470 header = []
470 if f in mmap:
471 if f in mmap:
471 to = getfile(f).read(mmap[f])
472 to = getfile(f).read(mmap[f])
472 if f not in removed:
473 if f not in removed:
@@ -480,7 +481,6 b' def diff(repo, node1=None, node2=None, f'
480 header.append('new mode %s\n' % nmode)
481 header.append('new mode %s\n' % nmode)
481
482
482 a, b = f, f
483 a, b = f, f
483 header = []
484 if f in added:
484 if f in added:
485 if node2:
485 if node2:
486 mode = gitmode(mmap2.execf(f))
486 mode = gitmode(mmap2.execf(f))
@@ -510,11 +510,12 b' def diff(repo, node1=None, node2=None, f'
510 nmode = gitmode(util.is_exec(repo.wjoin(f), mmap.execf(f)))
510 nmode = gitmode(util.is_exec(repo.wjoin(f), mmap.execf(f)))
511 addmodehdr(header, omode, nmode)
511 addmodehdr(header, omode, nmode)
512 r = None
512 r = None
513 if dodiff:
513 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b))
514 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b))
514 if dodiff:
515 text = mdiff.unidiff(to, date1, tn, date2(f), f, r, opts=opts)
516 if text or len(header) > 1:
515 fp.write(''.join(header))
517 fp.write(''.join(header))
516 if dodiff:
518 fp.write(text)
517 fp.write(mdiff.unidiff(to, date1, tn, date2(f), f, r, opts=opts))
518
519
519 def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False,
520 def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False,
520 opts=None):
521 opts=None):
General Comments 0
You need to be logged in to leave comments. Login now