ref: c94b2c037f60abab321e53239ab4b49bf0da6b4e
parent: 641589f25d1a5d86caa8c006fd659a145a561b72
author: phil9 <telephil9@gmail.com>
date: Mon Aug 2 05:39:07 EDT 2021
handle patch using a/ and b/ as filename prefixes some patches use a/ and b/ as prefixes for the sources and target file names (e.g. mercurial patches). the computed filename used for plumbing now takes this format into account.
--- a/vdiff.c
+++ b/vdiff.c
@@ -207,10 +207,10 @@
{
Biobuf *bp;
Line *l;
- char *s;
- char *f;
- int n;
+ char *s, *f, *t;
+ int n, ab;
+ ab = 0;
n = 0;
f = nil;
lsize = 64;
@@ -226,9 +226,16 @@
if(s==nil)
break;
l = parseline(f, n, s);
- if(l->t == Lfile && l->s[0] == '+')
+ if(l->t == Lfile && l->s[0] == '-' && strncmp(l->s+4, "a/", 2)==0)
+ ab = 1;
+ if(l->t == Lfile && l->s[0] == '+'){
f = l->s+4;
- else if(l->t == Lsep)
+ if(ab && strncmp(f, "b/", 2)==0)
+ f += 1;
+ t = strchr(f, '\t');
+ if(t!=nil)
+ *t = 0;
+ }else if(l->t == Lsep)
n = lineno(l->s);
else if(l->t == Ladd || l->t == Lnone)
++n;