##// END OF EJS Templates
git binary patches: don't print the header for identical files
Alexis S. L. Carvalho -
r4106:797dbdd4 default
parent child Browse files
Show More
@@ -415,14 +415,15 b' def b85diff(fp, to, tn):'
415 tohash = gitindex(to)
415 tohash = gitindex(to)
416 tnhash = gitindex(tn)
416 tnhash = gitindex(tn)
417 if tohash == tnhash:
417 if tohash == tnhash:
418 return
418 return ""
419
419 # TODO: deltas
420 # TODO: deltas
420 fp.write('index %s..%s\nGIT binary patch\nliteral %s\n' %
421 ret = ['index %s..%s\nGIT binary patch\nliteral %s\n' %
421 (tohash, tnhash, len(tn)))
422 (tohash, tnhash, len(tn))]
422
423 for l in chunk(zlib.compress(tn)):
423 tn = ''.join([fmtline(l) for l in chunk(zlib.compress(tn))])
424 ret.append(fmtline(l))
424 fp.write(tn)
425 ret.append('\n')
425 fp.write('\n')
426 return ''.join(ret)
426
427
427 def diff(repo, node1=None, node2=None, files=None, match=util.always,
428 def diff(repo, node1=None, node2=None, files=None, match=util.always,
428 fp=None, changes=None, opts=None):
429 fp=None, changes=None, opts=None):
@@ -615,11 +616,11 b' def diff(repo, node1=None, node2=None, f'
615 dodiff = 'binary'
616 dodiff = 'binary'
616 r = None
617 r = None
617 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b))
618 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b))
618 if dodiff == 'binary':
619 if dodiff:
619 fp.write(''.join(header))
620 if dodiff == 'binary':
620 b85diff(fp, to, tn)
621 text = b85diff(fp, to, tn)
621 elif dodiff:
622 else:
622 text = mdiff.unidiff(to, date1, tn, date2(f), f, r, opts=opts)
623 text = mdiff.unidiff(to, date1, tn, date2(f), f, r, opts=opts)
623 if text or len(header) > 1:
624 if text or len(header) > 1:
624 fp.write(''.join(header))
625 fp.write(''.join(header))
625 fp.write(text)
626 fp.write(text)
@@ -21,4 +21,3 b' zXmmQA+wDgE!qR9o8jr`%=ab_&uh(l?R=r;Tjiqo'
21 gQItJW-{SoTm)8|5##k|m00000NkvXXu0mjf3JwksH2?qr
21 gQItJW-{SoTm)8|5##k|m00000NkvXXu0mjf3JwksH2?qr
22
22
23 % diff --git -r 0 -r 2
23 % diff --git -r 0 -r 2
24 diff --git a/binfile.bin b/binfile.bin
General Comments 0
You need to be logged in to leave comments. Login now