Hex Artifact Content
Not logged in

Artifact 1c16a914bcf35ae982e012d203fe0fd9bacdc0e7:

Attachment "full-diff.diff" to ticket [e90d38c205] added by anonymous 2010-10-14 16:29:07.
0000: 41 44 44 45 44 20 20 20 20 6d 6f 74 64 0a 49 6e  ADDED    motd.In
0010: 64 65 78 3a 20 73 72 63 2f 64 69 66 66 63 6d 64  dex: src/diffcmd
0020: 2e 63 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  .c.=============
0030: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0040: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0050: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0060: 3d 3d 3d 3d 3d 3d 0a 2d 2d 2d 20 73 72 63 2f 64  ======.--- src/d
0070: 69 66 66 63 6d 64 2e 63 0a 2b 2b 2b 20 73 72 63  iffcmd.c.+++ src
0080: 2f 64 69 66 66 63 6d 64 2e 63 0a 40 40 20 2d 35  /diffcmd.c.@@ -5
0090: 31 2c 31 31 20 2b 35 31 2c 31 32 20 40 40 0a 20  1,11 +51,12 @@. 
00a0: 2a 2a 20 63 6f 6d 6d 61 6e 64 20 7a 44 69 66 66  ** command zDiff
00b0: 43 6d 64 20 74 6f 20 64 6f 20 74 68 65 20 64 69  Cmd to do the di
00c0: 66 66 69 6e 67 2e 0a 20 2a 2f 0a 20 73 74 61 74  ffing.. */. stat
00d0: 69 63 20 76 6f 69 64 20 64 69 66 66 5f 66 69 6c  ic void diff_fil
00e0: 65 28 0a 20 20 20 42 6c 6f 62 20 2a 70 46 69 6c  e(.   Blob *pFil
00f0: 65 31 2c 20 20 20 20 20 20 20 20 20 20 20 20 20  e1,             
0100: 2f 2a 20 49 6e 20 6d 65 6d 6f 72 79 20 63 6f 6e  /* In memory con
0110: 74 65 6e 74 20 74 6f 20 63 6f 6d 70 61 72 65 20  tent to compare 
0120: 66 72 6f 6d 20 2a 2f 0a 20 20 20 63 6f 6e 73 74  from */.   const
0130: 20 63 68 61 72 20 2a 7a 46 69 6c 65 32 2c 20 20   char *zFile2,  
0140: 20 20 20 20 20 2f 2a 20 4f 6e 20 64 69 73 6b 20       /* On disk 
0150: 63 6f 6e 74 65 6e 74 20 74 6f 20 63 6f 6d 70 61  content to compa
0160: 72 65 20 74 6f 20 2a 2f 0a 2d 20 20 63 6f 6e 73  re to */.-  cons
0170: 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65 2c 20 20  t char *zName,  
0180: 20 20 20 20 20 20 2f 2a 20 44 69 73 70 6c 61 79        /* Display
0190: 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 66 69 6c   name of the fil
01a0: 65 20 2a 2f 0a 2b 20 20 63 6f 6e 73 74 20 63 68  e */.+  const ch
01b0: 61 72 20 2a 7a 4e 61 6d 65 31 2c 20 20 20 20 20  ar *zName1,     
01c0: 20 20 2f 2a 20 44 69 73 70 6c 61 79 20 6e 61 6d    /* Display nam
01d0: 65 20 6f 66 20 74 68 65 20 66 69 6c 65 20 28 66  e of the file (f
01e0: 72 6f 6d 29 20 2a 2f 0a 2b 20 20 63 6f 6e 73 74  rom) */.+  const
01f0: 20 63 68 61 72 20 2a 7a 4e 61 6d 65 32 2c 20 20   char *zName2,  
0200: 20 20 20 20 20 2f 2a 20 44 69 73 70 6c 61 79 20       /* Display 
0210: 6e 61 6d 65 20 6f 66 20 74 68 65 20 66 69 6c 65  name of the file
0220: 20 28 74 6f 29 20 2a 2f 0a 20 20 20 63 6f 6e 73   (to) */.   cons
0230: 74 20 63 68 61 72 20 2a 7a 44 69 66 66 43 6d 64  t char *zDiffCmd
0240: 2c 20 20 20 20 20 2f 2a 20 43 6f 6d 6d 61 6e 64  ,     /* Command
0250: 20 66 6f 72 20 63 6f 6d 70 61 72 69 73 6f 6e 20   for comparison 
0260: 2a 2f 0a 20 20 20 69 6e 74 20 69 67 6e 6f 72 65  */.   int ignore
0270: 45 6f 6c 57 73 20 20 20 20 20 20 20 20 20 20 20  EolWs           
0280: 2f 2a 20 49 67 6e 6f 72 65 20 77 68 69 74 65 73  /* Ignore whites
0290: 70 61 63 65 20 61 74 20 65 6e 64 20 6f 66 20 6c  pace at end of l
02a0: 69 6e 65 73 20 2a 2f 0a 20 29 7b 0a 20 20 20 69  ines */. ){.   i
02b0: 66 28 20 7a 44 69 66 66 43 6d 64 3d 3d 30 20 29  f( zDiffCmd==0 )
02c0: 7b 0a 20 20 20 20 20 42 6c 6f 62 20 6f 75 74 3b  {.     Blob out;
02d0: 20 20 20 20 20 20 2f 2a 20 44 69 66 66 20 6f 75        /* Diff ou
02e0: 74 70 75 74 20 74 65 78 74 20 2a 2f 0a 40 40 20  tput text */.@@ 
02f0: 2d 36 36 2c 31 31 20 2b 36 37 2c 31 31 20 40 40  -66,11 +67,11 @@
0300: 0a 20 20 20 20 20 62 6c 6f 62 5f 72 65 61 64 5f  .     blob_read_
0310: 66 72 6f 6d 5f 66 69 6c 65 28 26 66 69 6c 65 32  from_file(&file2
0320: 2c 20 7a 46 69 6c 65 32 29 3b 0a 20 0a 20 20 20  , zFile2);. .   
0330: 20 20 2f 2a 20 43 6f 6d 70 75 74 65 20 61 6e 64    /* Compute and
0340: 20 6f 75 74 70 75 74 20 74 68 65 20 64 69 66 66   output the diff
0350: 65 72 65 6e 63 65 73 20 2a 2f 0a 20 20 20 20 20  erences */.     
0360: 62 6c 6f 62 5f 7a 65 72 6f 28 26 6f 75 74 29 3b  blob_zero(&out);
0370: 0a 20 20 20 20 20 74 65 78 74 5f 64 69 66 66 28  .     text_diff(
0380: 70 46 69 6c 65 31 2c 20 26 66 69 6c 65 32 2c 20  pFile1, &file2, 
0390: 26 6f 75 74 2c 20 35 2c 20 69 67 6e 6f 72 65 45  &out, 5, ignoreE
03a0: 6f 6c 57 73 29 3b 0a 2d 20 20 20 20 70 72 69 6e  olWs);.-    prin
03b0: 74 66 28 22 2d 2d 2d 20 25 73 5c 6e 2b 2b 2b 20  tf("--- %s\n+++ 
03c0: 25 73 5c 6e 22 2c 20 7a 4e 61 6d 65 2c 20 7a 4e  %s\n", zName, zN
03d0: 61 6d 65 29 3b 0a 2b 20 20 20 20 70 72 69 6e 74  ame);.+    print
03e0: 66 28 22 2d 2d 2d 20 25 73 5c 6e 2b 2b 2b 20 25  f("--- %s\n+++ %
03f0: 73 5c 6e 22 2c 20 7a 4e 61 6d 65 31 2c 20 7a 4e  s\n", zName1, zN
0400: 61 6d 65 32 29 3b 0a 20 20 20 20 20 70 72 69 6e  ame2);.     prin
0410: 74 66 28 22 25 73 5c 6e 22 2c 20 62 6c 6f 62 5f  tf("%s\n", blob_
0420: 73 74 72 28 26 6f 75 74 29 29 3b 0a 20 0a 20 20  str(&out));. .  
0430: 20 20 20 2f 2a 20 52 65 6c 65 61 73 65 20 6d 65     /* Release me
0440: 6d 6f 72 79 20 72 65 73 6f 75 72 63 65 73 20 2a  mory resources *
0450: 2f 0a 20 20 20 20 20 62 6c 6f 62 5f 72 65 73 65  /.     blob_rese
0460: 74 28 26 66 69 6c 65 32 29 3b 0a 20 20 20 20 20  t(&file2);.     
0470: 62 6c 6f 62 5f 72 65 73 65 74 28 26 6f 75 74 29  blob_reset(&out)
0480: 3b 0a 40 40 20 2d 31 35 38 2c 31 30 20 2b 31 35  ;.@@ -158,10 +15
0490: 39 2c 36 33 20 40 40 0a 20 20 20 20 20 62 6c 6f  9,63 @@.     blo
04a0: 62 5f 72 65 73 65 74 28 26 63 6d 64 29 3b 0a 20  b_reset(&cmd);. 
04b0: 20 20 7d 0a 20 7d 0a 20 0a 20 2f 2a 0a 2b 2a 2a    }. }. . /*.+**
04c0: 20 53 68 6f 77 20 74 68 65 20 64 69 66 66 65 72   Show the differ
04d0: 65 6e 63 65 20 66 6f 72 20 61 20 6e 65 77 6c 79  ence for a newly
04e0: 20 61 64 64 65 64 20 6f 72 20 64 65 6c 65 74 65   added or delete
04f0: 64 20 66 69 6c 65 2e 0a 2b 2a 2a 0a 2b 2a 2a 20  d file..+**.+** 
0500: 54 68 65 20 64 69 66 66 65 72 65 6e 63 65 20 69  The difference i
0510: 73 20 74 68 65 20 73 65 74 20 6f 66 20 65 64 69  s the set of edi
0520: 74 73 20 6e 65 65 64 65 64 20 74 6f 20 74 72 61  ts needed to tra
0530: 6e 73 66 6f 72 6d 20 61 6e 20 65 6d 70 74 79 20  nsform an empty 
0540: 66 69 6c 65 20 69 6e 74 6f 0a 2b 2a 2a 20 70 46  file into.+** pF
0550: 69 6c 65 20 6f 72 20 74 68 65 20 72 65 76 65 72  ile or the rever
0560: 73 65 2e 0a 2b 2a 2a 0a 2b 2a 2a 20 66 72 6f 6d  se..+**.+** from
0570: 4e 75 6c 6c 20 64 65 74 65 72 6d 69 6e 65 73 20  Null determines 
0580: 74 68 65 20 64 69 72 65 63 74 69 6f 6e 20 6f 66  the direction of
0590: 20 74 68 65 20 64 69 66 66 2e 0a 2b 2a 2a 0a 2b   the diff..+**.+
05a0: 2a 2a 20 55 73 65 20 74 68 65 20 69 6e 74 65 72  ** Use the inter
05b0: 6e 61 6c 20 64 69 66 66 20 6c 6f 67 69 63 20 69  nal diff logic i
05c0: 66 20 7a 44 69 66 66 43 6d 64 20 69 73 20 4e 55  f zDiffCmd is NU
05d0: 4c 4c 2e 20 20 4f 74 68 65 72 77 69 73 65 20 63  LL.  Otherwise c
05e0: 61 6c 6c 20 74 68 65 0a 2b 2a 2a 20 63 6f 6d 6d  all the.+** comm
05f0: 61 6e 64 20 7a 44 69 66 66 43 6d 64 20 74 6f 20  and zDiffCmd to 
0600: 64 6f 20 74 68 65 20 64 69 66 66 69 6e 67 2e 0a  do the diffing..
0610: 2b 2a 2f 0a 2b 73 74 61 74 69 63 20 76 6f 69 64  +*/.+static void
0620: 20 64 69 66 66 5f 66 69 6c 65 5f 72 65 6d 6f 76   diff_file_remov
0630: 65 64 28 0a 2b 20 20 42 6c 6f 62 20 2a 70 46 69  ed(.+  Blob *pFi
0640: 6c 65 2c 20 20 20 20 20 20 20 20 20 20 20 20 20  le,             
0650: 20 2f 2a 20 43 6f 6e 74 65 6e 74 20 74 6f 20 75   /* Content to u
0660: 73 65 20 2a 2f 0a 2b 20 20 63 6f 6e 73 74 20 63  se */.+  const c
0670: 68 61 72 20 2a 7a 4e 61 6d 65 2c 20 20 20 20 20  har *zName,     
0680: 20 20 20 2f 2a 20 44 69 73 70 6c 61 79 20 6e 61     /* Display na
0690: 6d 65 20 6f 66 20 74 68 65 20 66 69 6c 65 20 2a  me of the file *
06a0: 2f 0a 2b 20 20 63 6f 6e 73 74 20 63 68 61 72 20  /.+  const char 
06b0: 2a 7a 44 69 66 66 43 6d 64 2c 20 20 20 20 20 2f  *zDiffCmd,     /
06c0: 2a 20 43 6f 6d 6d 61 6e 64 20 66 6f 72 20 63 6f  * Command for co
06d0: 6d 70 61 72 69 73 6f 6e 20 2a 2f 0a 2b 20 20 69  mparison */.+  i
06e0: 6e 74 20 69 67 6e 6f 72 65 45 6f 6c 57 73 20 20  nt ignoreEolWs  
06f0: 20 20 20 20 20 20 20 20 20 2f 2a 20 49 67 6e 6f           /* Igno
0700: 72 65 20 77 68 69 74 65 73 70 61 63 65 20 61 74  re whitespace at
0710: 20 65 6e 64 20 6f 66 20 6c 69 6e 65 73 20 2a 2f   end of lines */
0720: 0a 2b 29 7b 0a 2b 20 20 69 66 28 20 7a 44 69 66  .+){.+  if( zDif
0730: 66 43 6d 64 3d 3d 30 20 29 7b 0a 2b 20 20 20 20  fCmd==0 ){.+    
0740: 42 6c 6f 62 20 6f 75 74 3b 20 20 20 20 20 20 2f  Blob out;      /
0750: 2a 20 44 69 66 66 20 6f 75 74 70 75 74 20 74 65  * Diff output te
0760: 78 74 20 2a 2f 0a 2b 20 20 20 20 42 6c 6f 62 20  xt */.+    Blob 
0770: 6e 75 6c 6c 42 6c 6f 62 3b 0a 2b 0a 2b 20 20 20  nullBlob;.+.+   
0780: 20 62 6c 6f 62 5f 7a 65 72 6f 28 26 6f 75 74 29   blob_zero(&out)
0790: 3b 0a 2b 20 20 20 20 62 6c 6f 62 5f 7a 65 72 6f  ;.+    blob_zero
07a0: 28 26 6e 75 6c 6c 42 6c 6f 62 29 3b 0a 2b 20 20  (&nullBlob);.+  
07b0: 20 20 74 65 78 74 5f 64 69 66 66 28 70 46 69 6c    text_diff(pFil
07c0: 65 2c 20 26 6e 75 6c 6c 42 6c 6f 62 2c 20 26 6f  e, &nullBlob, &o
07d0: 75 74 2c 20 35 2c 20 69 67 6e 6f 72 65 45 6f 6c  ut, 5, ignoreEol
07e0: 57 73 29 3b 0a 2b 20 20 20 20 70 72 69 6e 74 66  Ws);.+    printf
07f0: 28 22 2d 2d 2d 20 25 73 5c 6e 2b 2b 2b 20 2f 64  ("--- %s\n+++ /d
0800: 65 76 2f 6e 75 6c 6c 5c 6e 22 2c 20 7a 4e 61 6d  ev/null\n", zNam
0810: 65 29 3b 0a 2b 20 20 20 20 70 72 69 6e 74 66 28  e);.+    printf(
0820: 22 25 73 5c 6e 22 2c 20 62 6c 6f 62 5f 73 74 72  "%s\n", blob_str
0830: 28 26 6f 75 74 29 29 3b 0a 2b 0a 2b 20 20 20 20  (&out));.+.+    
0840: 2f 2a 20 52 65 6c 65 61 73 65 20 6d 65 6d 6f 72  /* Release memor
0850: 79 20 72 65 73 6f 75 72 63 65 73 20 2a 2f 0a 2b  y resources */.+
0860: 20 20 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26      blob_reset(&
0870: 6f 75 74 29 3b 0a 2b 20 20 20 20 62 6c 6f 62 5f  out);.+    blob_
0880: 72 65 73 65 74 28 26 6e 75 6c 6c 42 6c 6f 62 29  reset(&nullBlob)
0890: 3b 0a 2b 20 20 7d 65 6c 73 65 7b 0a 2b 20 20 20  ;.+  }else{.+   
08a0: 20 42 6c 6f 62 20 63 6d 64 3b 0a 2b 20 20 20 20   Blob cmd;.+    
08b0: 63 68 61 72 20 7a 54 65 6d 70 5b 33 30 30 5d 3b  char zTemp[300];
08c0: 0a 2b 0a 2b 20 20 20 20 2f 2a 20 43 6f 6e 73 74  .+.+    /* Const
08d0: 72 75 63 74 20 61 20 74 65 6d 70 6f 72 61 72 79  ruct a temporary
08e0: 20 66 69 6c 65 20 6e 61 6d 65 73 20 2a 2f 0a 2b   file names */.+
08f0: 20 20 20 20 66 69 6c 65 5f 74 65 6d 70 6e 61 6d      file_tempnam
0900: 65 28 73 69 7a 65 6f 66 28 7a 54 65 6d 70 29 2c  e(sizeof(zTemp),
0910: 20 7a 54 65 6d 70 29 3b 0a 2b 20 20 20 20 62 6c   zTemp);.+    bl
0920: 6f 62 5f 77 72 69 74 65 5f 74 6f 5f 66 69 6c 65  ob_write_to_file
0930: 28 70 46 69 6c 65 2c 20 7a 54 65 6d 70 29 3b 0a  (pFile, zTemp);.
0940: 2b 0a 2b 20 20 20 20 2f 2a 20 43 6f 6e 73 74 72  +.+    /* Constr
0950: 75 63 74 20 74 68 65 20 65 78 74 65 72 6e 61 6c  uct the external
0960: 20 64 69 66 66 20 63 6f 6d 6d 61 6e 64 20 2a 2f   diff command */
0970: 0a 2b 20 20 20 20 62 6c 6f 62 5f 7a 65 72 6f 28  .+    blob_zero(
0980: 26 63 6d 64 29 3b 0a 2b 20 20 20 20 62 6c 6f 62  &cmd);.+    blob
0990: 5f 61 70 70 65 6e 64 66 28 26 63 6d 64 2c 20 22  _appendf(&cmd, "
09a0: 25 73 20 22 2c 20 7a 44 69 66 66 43 6d 64 29 3b  %s ", zDiffCmd);
09b0: 0a 2b 20 20 20 20 73 68 65 6c 6c 5f 65 73 63 61  .+    shell_esca
09c0: 70 65 28 26 63 6d 64 2c 20 7a 54 65 6d 70 29 3b  pe(&cmd, zTemp);
09d0: 0a 2b 20 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e  .+    blob_appen
09e0: 64 28 26 63 6d 64 2c 20 22 20 2f 64 65 76 2f 6e  d(&cmd, " /dev/n
09f0: 75 6c 6c 22 2c 20 31 29 3b 0a 2b 0a 2b 20 20 20  ull", 1);.+.+   
0a00: 20 2f 2a 20 52 75 6e 20 74 68 65 20 65 78 74 65   /* Run the exte
0a10: 72 6e 61 6c 20 64 69 66 66 20 63 6f 6d 6d 61 6e  rnal diff comman
0a20: 64 20 2a 2f 0a 2b 20 20 20 20 70 6f 72 74 61 62  d */.+    portab
0a30: 6c 65 5f 73 79 73 74 65 6d 28 62 6c 6f 62 5f 73  le_system(blob_s
0a40: 74 72 28 26 63 6d 64 29 29 3b 0a 2b 0a 2b 20 20  tr(&cmd));.+.+  
0a50: 20 20 2f 2a 20 44 65 6c 65 74 65 20 74 68 65 20    /* Delete the 
0a60: 74 65 6d 70 6f 72 61 72 79 20 66 69 6c 65 20 61  temporary file a
0a70: 6e 64 20 63 6c 65 61 6e 20 75 70 20 6d 65 6d 6f  nd clean up memo
0a80: 72 79 20 75 73 65 64 20 2a 2f 0a 2b 20 20 20 20  ry used */.+    
0a90: 75 6e 6c 69 6e 6b 28 7a 54 65 6d 70 29 3b 0a 2b  unlink(zTemp);.+
0aa0: 20 20 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26      blob_reset(&
0ab0: 63 6d 64 29 3b 0a 2b 20 20 7d 0a 2b 7d 0a 2b 0a  cmd);.+  }.+}.+.
0ac0: 2b 2f 2a 0a 20 2a 2a 20 44 6f 20 61 20 64 69 66  +/*. ** Do a dif
0ad0: 66 20 61 67 61 69 6e 73 74 20 61 20 73 69 6e 67  f against a sing
0ae0: 6c 65 20 66 69 6c 65 20 6e 61 6d 65 64 20 69 6e  le file named in
0af0: 20 67 2e 61 72 67 76 5b 32 5d 20 66 72 6f 6d 20   g.argv[2] from 
0b00: 76 65 72 73 69 6f 6e 20 7a 46 72 6f 6d 0a 20 2a  version zFrom. *
0b10: 2a 20 61 67 61 69 6e 73 74 20 74 68 65 20 73 61  * against the sa
0b20: 6d 65 20 66 69 6c 65 20 6f 6e 20 64 69 73 6b 2e  me file on disk.
0b30: 0a 20 2a 2f 0a 20 73 74 61 74 69 63 20 76 6f 69  . */. static voi
0b40: 64 20 64 69 66 66 5f 6f 6e 65 5f 61 67 61 69 6e  d diff_one_again
0b50: 73 74 5f 64 69 73 6b 28 0a 20 20 20 63 6f 6e 73  st_disk(.   cons
0b60: 74 20 63 68 61 72 20 2a 7a 46 72 6f 6d 2c 20 20  t char *zFrom,  
0b70: 20 20 20 20 20 20 2f 2a 20 4e 61 6d 65 20 6f 66        /* Name of
0b80: 20 66 69 6c 65 20 2a 2f 0a 40 40 20 2d 31 37 30   file */.@@ -170
0b90: 2c 31 31 20 2b 32 32 34 2c 31 31 20 40 40 0a 20  ,11 +224,11 @@. 
0ba0: 29 7b 0a 20 20 20 42 6c 6f 62 20 66 6e 61 6d 65  ){.   Blob fname
0bb0: 3b 0a 20 20 20 42 6c 6f 62 20 63 6f 6e 74 65 6e  ;.   Blob conten
0bc0: 74 3b 0a 20 20 20 66 69 6c 65 5f 74 72 65 65 5f  t;.   file_tree_
0bd0: 6e 61 6d 65 28 67 2e 61 72 67 76 5b 32 5d 2c 20  name(g.argv[2], 
0be0: 26 66 6e 61 6d 65 2c 20 31 29 3b 0a 20 20 20 68  &fname, 1);.   h
0bf0: 69 73 74 6f 72 69 63 61 6c 5f 76 65 72 73 69 6f  istorical_versio
0c00: 6e 5f 6f 66 5f 66 69 6c 65 28 7a 46 72 6f 6d 2c  n_of_file(zFrom,
0c10: 20 62 6c 6f 62 5f 73 74 72 28 26 66 6e 61 6d 65   blob_str(&fname
0c20: 29 2c 20 26 63 6f 6e 74 65 6e 74 2c 20 30 29 3b  ), &content, 0);
0c30: 0a 2d 20 20 64 69 66 66 5f 66 69 6c 65 28 26 63  .-  diff_file(&c
0c40: 6f 6e 74 65 6e 74 2c 20 67 2e 61 72 67 76 5b 32  ontent, g.argv[2
0c50: 5d 2c 20 67 2e 61 72 67 76 5b 32 5d 2c 20 7a 44  ], g.argv[2], zD
0c60: 69 66 66 43 6d 64 2c 20 69 67 6e 6f 72 65 45 6f  iffCmd, ignoreEo
0c70: 6c 57 73 29 3b 0a 2b 20 20 64 69 66 66 5f 66 69  lWs);.+  diff_fi
0c80: 6c 65 28 26 63 6f 6e 74 65 6e 74 2c 20 67 2e 61  le(&content, g.a
0c90: 72 67 76 5b 32 5d 2c 20 67 2e 61 72 67 76 5b 32  rgv[2], g.argv[2
0ca0: 5d 2c 20 67 2e 61 72 67 76 5b 32 5d 2c 20 7a 44  ], g.argv[2], zD
0cb0: 69 66 66 43 6d 64 2c 20 69 67 6e 6f 72 65 45 6f  iffCmd, ignoreEo
0cc0: 6c 57 73 29 3b 0a 20 20 20 62 6c 6f 62 5f 72 65  lWs);.   blob_re
0cd0: 73 65 74 28 26 63 6f 6e 74 65 6e 74 29 3b 0a 20  set(&content);. 
0ce0: 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 66 6e    blob_reset(&fn
0cf0: 61 6d 65 29 3b 0a 20 7d 0a 20 0a 20 2f 2a 0a 40  ame);. }. . /*.@
0d00: 40 20 2d 31 38 33 2c 31 30 20 2b 32 33 37 2c 31  @ -183,10 +237,1
0d10: 31 20 40 40 0a 20 2a 2a 20 66 69 6c 65 73 20 6f  1 @@. ** files o
0d20: 6e 20 64 69 73 6b 20 61 6e 64 20 74 68 65 20 63  n disk and the c
0d30: 68 65 63 6b 2d 6f 75 74 20 6f 6e 20 77 68 69 63  heck-out on whic
0d40: 68 20 74 68 65 79 20 61 72 65 20 62 61 73 65 64  h they are based
0d50: 2e 0a 20 2a 2f 0a 20 73 74 61 74 69 63 20 76 6f  .. */. static vo
0d60: 69 64 20 64 69 66 66 5f 61 6c 6c 5f 61 67 61 69  id diff_all_agai
0d70: 6e 73 74 5f 64 69 73 6b 28 0a 20 20 20 63 6f 6e  nst_disk(.   con
0d80: 73 74 20 63 68 61 72 20 2a 7a 46 72 6f 6d 2c 20  st char *zFrom, 
0d90: 20 20 20 20 20 20 20 2f 2a 20 56 65 72 73 69 6f         /* Versio
0da0: 6e 20 74 6f 20 64 69 66 66 65 72 65 6e 63 65 20  n to difference 
0db0: 66 72 6f 6d 20 2a 2f 0a 20 20 20 63 6f 6e 73 74  from */.   const
0dc0: 20 63 68 61 72 20 2a 7a 44 69 66 66 43 6d 64 2c   char *zDiffCmd,
0dd0: 20 20 20 20 20 2f 2a 20 55 73 65 20 74 68 69 73       /* Use this
0de0: 20 64 69 66 66 20 63 6f 6d 6d 61 6e 64 2e 20 20   diff command.  
0df0: 4e 55 4c 4c 20 66 6f 72 20 62 75 69 6c 74 2d 69  NULL for built-i
0e00: 6e 20 2a 2f 0a 2b 20 20 69 6e 74 20 66 75 6c 6c  n */.+  int full
0e10: 44 69 66 66 2c 20 20 20 20 20 20 20 20 20 20 20  Diff,           
0e20: 20 20 2f 2a 20 49 6e 63 6c 75 64 65 20 61 64 64    /* Include add
0e30: 65 64 20 6f 72 20 72 65 6d 6f 76 65 20 66 69 6c  ed or remove fil
0e40: 65 73 20 2a 2f 0a 20 20 20 69 6e 74 20 69 67 6e  es */.   int ign
0e50: 6f 72 65 45 6f 6c 57 73 20 20 20 20 20 20 20 20  oreEolWs        
0e60: 20 20 20 2f 2a 20 49 67 6e 6f 72 65 20 65 6e 64     /* Ignore end
0e70: 2d 6f 66 2d 6c 69 6e 65 20 77 68 69 74 65 73 70  -of-line whitesp
0e80: 61 63 65 20 2a 2f 0a 20 29 7b 0a 20 20 20 69 6e  ace */. ){.   in
0e90: 74 20 76 69 64 3b 0a 20 20 20 42 6c 6f 62 20 73  t vid;.   Blob s
0ea0: 71 6c 3b 0a 20 20 20 53 74 6d 74 20 71 3b 0a 40  ql;.   Stmt q;.@
0eb0: 40 20 2d 32 33 36 2c 32 38 20 2b 32 39 31 2c 34  @ -236,28 +291,4
0ec0: 35 20 40 40 0a 20 20 20 20 20 63 6f 6e 73 74 20  5 @@.     const 
0ed0: 63 68 61 72 20 2a 7a 50 61 74 68 6e 61 6d 65 20  char *zPathname 
0ee0: 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74  = db_column_text
0ef0: 28 26 71 2c 30 29 3b 0a 20 20 20 20 20 69 6e 74  (&q,0);.     int
0f00: 20 69 73 44 65 6c 65 74 65 64 20 3d 20 64 62 5f   isDeleted = db_
0f10: 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 31  column_int(&q, 1
0f20: 29 3b 0a 20 20 20 20 20 69 6e 74 20 69 73 43 68  );.     int isCh
0f30: 6e 67 65 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e  nged = db_column
0f40: 5f 69 6e 74 28 26 71 2c 32 29 3b 0a 20 20 20 20  _int(&q,2);.    
0f50: 20 69 6e 74 20 69 73 4e 65 77 20 3d 20 64 62 5f   int isNew = db_
0f60: 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 33 29  column_int(&q,3)
0f70: 3b 0a 20 20 20 20 20 63 68 61 72 20 2a 7a 46 75  ;.     char *zFu
0f80: 6c 6c 4e 61 6d 65 20 3d 20 6d 70 72 69 6e 74 66  llName = mprintf
0f90: 28 22 25 73 25 73 22 2c 20 67 2e 7a 4c 6f 63 61  ("%s%s", g.zLoca
0fa0: 6c 52 6f 6f 74 2c 20 7a 50 61 74 68 6e 61 6d 65  lRoot, zPathname
0fb0: 29 3b 0a 2d 20 20 20 20 69 66 28 20 69 73 44 65  );.-    if( isDe
0fc0: 6c 65 74 65 64 20 29 7b 0a 2d 20 20 20 20 20 20  leted ){.-      
0fd0: 70 72 69 6e 74 66 28 22 44 45 4c 45 54 45 44 20  printf("DELETED 
0fe0: 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e 61 6d   %s\n", zPathnam
0ff0: 65 29 3b 0a 2d 20 20 20 20 7d 65 6c 73 65 20 69  e);.-    }else i
1000: 66 28 20 61 63 63 65 73 73 28 7a 46 75 6c 6c 4e  f( access(zFullN
1010: 61 6d 65 2c 20 30 29 20 29 7b 0a 2d 20 20 20 20  ame, 0) ){.-    
1020: 20 20 70 72 69 6e 74 66 28 22 4d 49 53 53 49 4e    printf("MISSIN
1030: 47 20 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e  G  %s\n", zPathn
1040: 61 6d 65 29 3b 0a 2d 20 20 20 20 7d 65 6c 73 65  ame);.-    }else
1050: 20 69 66 28 20 69 73 4e 65 77 20 29 7b 0a 2d 20   if( isNew ){.- 
1060: 20 20 20 20 20 70 72 69 6e 74 66 28 22 41 44 44       printf("ADD
1070: 45 44 20 20 20 20 25 73 5c 6e 22 2c 20 7a 50 61  ED    %s\n", zPa
1080: 74 68 6e 61 6d 65 29 3b 0a 2d 20 20 20 20 7d 65  thname);.-    }e
1090: 6c 73 65 20 69 66 28 20 69 73 43 68 6e 67 65 64  lse if( isChnged
10a0: 3d 3d 33 20 29 7b 0a 2d 20 20 20 20 20 20 70 72  ==3 ){.-      pr
10b0: 69 6e 74 66 28 22 41 44 44 45 44 5f 42 59 5f 4d  intf("ADDED_BY_M
10c0: 45 52 47 45 20 25 73 5c 6e 22 2c 20 7a 50 61 74  ERGE %s\n", zPat
10d0: 68 6e 61 6d 65 29 3b 0a 2d 20 20 20 20 7d 65 6c  hname);.-    }el
10e0: 73 65 7b 0a 2d 20 20 20 20 20 20 69 6e 74 20 73  se{.-      int s
10f0: 72 63 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e  rcid = db_column
1100: 5f 69 6e 74 28 26 71 2c 20 34 29 3b 0a 2b 20 20  _int(&q, 4);.+  
1110: 20 20 69 6e 74 20 69 73 4d 69 73 73 69 6e 67 20    int isMissing 
1120: 3d 20 61 63 63 65 73 73 28 7a 46 75 6c 6c 4e 61  = access(zFullNa
1130: 6d 65 2c 20 30 29 3b 0a 2b 0a 2b 20 20 20 20 69  me, 0);.+.+    i
1140: 66 28 20 66 75 6c 6c 44 69 66 66 20 7c 7c 20 21  f( fullDiff || !
1150: 28 69 73 44 65 6c 65 74 65 64 20 7c 7c 20 69 73  (isDeleted || is
1160: 4e 65 77 20 7c 7c 20 69 73 4d 69 73 73 69 6e 67  New || isMissing
1170: 20 7c 7c 20 69 73 43 68 6e 67 65 64 3d 3d 33 29   || isChnged==3)
1180: 20 29 7b 0a 20 20 20 20 20 20 20 42 6c 6f 62 20   ){.       Blob 
1190: 63 6f 6e 74 65 6e 74 3b 0a 2d 20 20 20 20 20 20  content;.-      
11a0: 63 6f 6e 74 65 6e 74 5f 67 65 74 28 73 72 63 69  content_get(srci
11b0: 64 2c 20 26 63 6f 6e 74 65 6e 74 29 3b 0a 2b 20  d, &content);.+ 
11c0: 20 20 20 20 20 63 6f 6e 73 74 20 63 68 61 72 20       const char 
11d0: 2a 7a 50 61 74 68 6e 61 6d 65 53 72 63 3b 0a 2b  *zPathnameSrc;.+
11e0: 20 20 20 20 20 20 69 66 28 20 69 73 4e 65 77 20        if( isNew 
11f0: 7c 7c 20 69 73 43 68 6e 67 65 64 3d 3d 33 20 29  || isChnged==3 )
1200: 7b 0a 2b 20 20 20 20 20 20 20 20 62 6c 6f 62 5f  {.+        blob_
1210: 7a 65 72 6f 28 26 63 6f 6e 74 65 6e 74 29 3b 0a  zero(&content);.
1220: 2b 09 7a 50 61 74 68 6e 61 6d 65 53 72 63 20 3d  +.zPathnameSrc =
1230: 20 22 2f 64 65 76 2f 6e 75 6c 6c 22 3b 0a 2b 20   "/dev/null";.+ 
1240: 20 20 20 20 20 7d 65 6c 73 65 7b 0a 2b 20 20 20       }else{.+   
1250: 20 20 20 20 20 69 6e 74 20 73 72 63 69 64 20 3d       int srcid =
1260: 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26   db_column_int(&
1270: 71 2c 20 34 29 3b 0a 2b 20 20 20 20 20 20 20 20  q, 4);.+        
1280: 63 6f 6e 74 65 6e 74 5f 67 65 74 28 73 72 63 69  content_get(srci
1290: 64 2c 20 26 63 6f 6e 74 65 6e 74 29 3b 0a 2b 09  d, &content);.+.
12a0: 7a 50 61 74 68 6e 61 6d 65 53 72 63 20 3d 20 7a  zPathnameSrc = z
12b0: 50 61 74 68 6e 61 6d 65 3b 0a 2b 20 20 20 20 20  Pathname;.+     
12c0: 20 7d 0a 20 20 20 20 20 20 20 70 72 69 6e 74 66   }.       printf
12d0: 28 22 49 6e 64 65 78 3a 20 25 73 5c 6e 3d 3d 3d  ("Index: %s\n===
12e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
12f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1300: 3d 3d 3d 3d 22 0a 20 20 20 20 20 20 20 20 20 20  ====".          
1310: 20 20 20 20 22 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d      "===========
1320: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
1330: 3d 5c 6e 22 2c 0a 20 20 20 20 20 20 20 20 20 20  =\n",.          
1340: 20 20 20 20 7a 50 61 74 68 6e 61 6d 65 0a 20 20      zPathname.  
1350: 20 20 20 20 20 29 3b 0a 2d 20 20 20 20 20 20 64       );.-      d
1360: 69 66 66 5f 66 69 6c 65 28 26 63 6f 6e 74 65 6e  iff_file(&conten
1370: 74 2c 20 7a 46 75 6c 6c 4e 61 6d 65 2c 20 7a 50  t, zFullName, zP
1380: 61 74 68 6e 61 6d 65 2c 20 7a 44 69 66 66 43 6d  athname, zDiffCm
1390: 64 2c 20 69 67 6e 6f 72 65 45 6f 6c 57 73 29 3b  d, ignoreEolWs);
13a0: 0a 2b 20 20 20 20 20 20 69 66 28 20 69 73 44 65  .+      if( isDe
13b0: 6c 65 74 65 64 20 7c 7c 20 69 73 4d 69 73 73 69  leted || isMissi
13c0: 6e 67 20 29 7b 0a 2b 20 20 20 20 20 20 20 20 64  ng ){.+        d
13d0: 69 66 66 5f 66 69 6c 65 5f 72 65 6d 6f 76 65 64  iff_file_removed
13e0: 28 26 63 6f 6e 74 65 6e 74 2c 20 7a 50 61 74 68  (&content, zPath
13f0: 6e 61 6d 65 2c 20 7a 44 69 66 66 43 6d 64 2c 20  name, zDiffCmd, 
1400: 69 67 6e 6f 72 65 45 6f 6c 57 73 29 3b 0a 2b 20  ignoreEolWs);.+ 
1410: 20 20 20 20 20 7d 65 6c 73 65 7b 0a 2b 20 20 20       }else{.+   
1420: 20 20 20 20 20 64 69 66 66 5f 66 69 6c 65 28 26       diff_file(&
1430: 63 6f 6e 74 65 6e 74 2c 20 7a 46 75 6c 6c 4e 61  content, zFullNa
1440: 6d 65 2c 20 7a 50 61 74 68 6e 61 6d 65 53 72 63  me, zPathnameSrc
1450: 2c 20 7a 50 61 74 68 6e 61 6d 65 2c 20 7a 44 69  , zPathname, zDi
1460: 66 66 43 6d 64 2c 0a 2b 09 20 20 20 20 20 20 20  ffCmd,.+.       
1470: 20 20 20 69 67 6e 6f 72 65 45 6f 6c 57 73 0a 2b     ignoreEolWs.+
1480: 09 29 3b 0a 2b 20 20 20 20 20 20 7d 0a 20 20 20  .);.+      }.   
1490: 20 20 20 20 62 6c 6f 62 5f 72 65 73 65 74 28 26      blob_reset(&
14a0: 63 6f 6e 74 65 6e 74 29 3b 0a 2b 20 20 20 20 7d  content);.+    }
14b0: 65 6c 73 65 7b 0a 2b 20 20 20 20 20 20 69 66 28  else{.+      if(
14c0: 20 69 73 44 65 6c 65 74 65 64 20 29 7b 0a 2b 20   isDeleted ){.+ 
14d0: 20 20 20 20 20 20 20 70 72 69 6e 74 66 28 22 44         printf("D
14e0: 45 4c 45 54 45 44 20 20 25 73 5c 6e 22 2c 20 7a  ELETED  %s\n", z
14f0: 50 61 74 68 6e 61 6d 65 29 3b 0a 2b 20 20 20 20  Pathname);.+    
1500: 20 20 7d 65 6c 73 65 20 69 66 28 20 69 73 4d 69    }else if( isMi
1510: 73 73 69 6e 67 20 29 7b 0a 2b 20 20 20 20 20 20  ssing ){.+      
1520: 20 20 70 72 69 6e 74 66 28 22 4d 49 53 53 49 4e    printf("MISSIN
1530: 47 20 20 25 73 5c 6e 22 2c 20 7a 50 61 74 68 6e  G  %s\n", zPathn
1540: 61 6d 65 29 3b 0a 2b 20 20 20 20 20 20 7d 65 6c  ame);.+      }el
1550: 73 65 20 69 66 28 20 69 73 4e 65 77 20 29 7b 0a  se if( isNew ){.
1560: 2b 20 20 20 20 20 20 20 20 70 72 69 6e 74 66 28  +        printf(
1570: 22 41 44 44 45 44 20 20 20 20 25 73 5c 6e 22 2c  "ADDED    %s\n",
1580: 20 7a 50 61 74 68 6e 61 6d 65 29 3b 0a 2b 20 20   zPathname);.+  
1590: 20 20 20 20 7d 65 6c 73 65 20 69 66 28 20 69 73      }else if( is
15a0: 43 68 6e 67 65 64 3d 3d 33 29 7b 0a 2b 20 20 20  Chnged==3){.+   
15b0: 20 20 20 20 20 70 72 69 6e 74 66 28 22 41 44 44       printf("ADD
15c0: 45 44 5f 42 59 5f 4d 45 52 47 45 20 25 73 5c 6e  ED_BY_MERGE %s\n
15d0: 22 2c 20 7a 50 61 74 68 6e 61 6d 65 29 3b 0a 2b  ", zPathname);.+
15e0: 20 20 20 20 20 20 7d 0a 20 20 20 20 20 7d 0a 20        }.     }. 
15f0: 20 20 20 20 66 72 65 65 28 7a 46 75 6c 6c 4e 61      free(zFullNa
1600: 6d 65 29 3b 0a 20 20 20 7d 0a 20 20 20 64 62 5f  me);.   }.   db_
1610: 66 69 6e 61 6c 69 7a 65 28 26 71 29 3b 0a 20 20  finalize(&q);.  
1620: 20 64 62 5f 65 6e 64 5f 74 72 61 6e 73 61 63 74   db_end_transact
1630: 69 6f 6e 28 31 29 3b 20 20 2f 2a 20 52 4f 4c 4c  ion(1);  /* ROLL
1640: 42 41 43 4b 20 2a 2f 0a 40 40 20 2d 33 37 30 2c  BACK */.@@ -370,
1650: 31 36 20 2b 34 34 32 2c 31 38 20 40 40 0a 20 2a  16 +442,18 @@. *
1660: 2a 20 74 68 65 20 22 2d 69 22 20 6f 70 74 69 6f  * the "-i" optio
1670: 6e 20 69 73 20 61 20 6e 6f 2d 6f 70 2e 20 20 54  n is a no-op.  T
1680: 68 65 20 22 2d 69 22 20 6f 70 74 69 6f 6e 20 63  he "-i" option c
1690: 6f 6e 76 65 72 74 73 20 22 67 64 69 66 66 22 20  onverts "gdiff" 
16a0: 69 6e 74 6f 20 22 64 69 66 66 22 2e 0a 20 2a 2f  into "diff".. */
16b0: 0a 20 76 6f 69 64 20 64 69 66 66 5f 63 6d 64 28  . void diff_cmd(
16c0: 76 6f 69 64 29 7b 0a 20 20 20 69 6e 74 20 69 73  void){.   int is
16d0: 47 44 69 66 66 3b 20 20 20 20 20 20 20 20 20 20  GDiff;          
16e0: 20 20 20 20 20 2f 2a 20 54 72 75 65 20 66 6f 72       /* True for
16f0: 20 67 64 69 66 66 2e 20 20 46 61 6c 73 65 20 66   gdiff.  False f
1700: 6f 72 20 6e 6f 72 6d 61 6c 20 64 69 66 66 20 2a  or normal diff *
1710: 2f 0a 20 20 20 69 6e 74 20 69 73 49 6e 74 65 72  /.   int isInter
1720: 6e 44 69 66 66 3b 20 20 20 20 20 20 20 20 20 20  nDiff;          
1730: 2f 2a 20 54 72 75 65 20 66 6f 72 20 69 6e 74 65  /* True for inte
1740: 72 6e 61 6c 20 64 69 66 66 20 2a 2f 0a 2b 20 20  rnal diff */.+  
1750: 69 6e 74 20 69 73 46 75 6c 6c 44 69 66 66 3b 20  int isFullDiff; 
1760: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 54 72             /* Tr
1770: 75 65 20 66 6f 72 20 66 75 6c 6c 20 64 69 66 66  ue for full diff
1780: 73 20 2a 2f 0a 20 20 20 63 6f 6e 73 74 20 63 68  s */.   const ch
1790: 61 72 20 2a 7a 46 72 6f 6d 3b 20 20 20 20 20 20  ar *zFrom;      
17a0: 20 20 20 2f 2a 20 53 6f 75 72 63 65 20 76 65 72     /* Source ver
17b0: 73 69 6f 6e 20 6e 75 6d 62 65 72 20 2a 2f 0a 20  sion number */. 
17c0: 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 54    const char *zT
17d0: 6f 3b 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20  o;           /* 
17e0: 54 61 72 67 65 74 20 76 65 72 73 69 6f 6e 20 6e  Target version n
17f0: 75 6d 62 65 72 20 2a 2f 0a 20 20 20 63 6f 6e 73  umber */.   cons
1800: 74 20 63 68 61 72 20 2a 7a 44 69 66 66 43 6d 64  t char *zDiffCmd
1810: 20 3d 20 30 3b 20 20 2f 2a 20 45 78 74 65 72 6e   = 0;  /* Extern
1820: 61 6c 20 64 69 66 66 20 63 6f 6d 6d 61 6e 64 2e  al diff command.
1830: 20 4e 55 4c 4c 20 66 6f 72 20 69 6e 74 65 72 6e   NULL for intern
1840: 61 6c 20 64 69 66 66 20 2a 2f 0a 20 0a 20 20 20  al diff */. .   
1850: 69 73 47 44 69 66 66 20 3d 20 67 2e 61 72 67 76  isGDiff = g.argv
1860: 5b 31 5d 5b 30 5d 3d 3d 27 67 27 3b 0a 20 20 20  [1][0]=='g';.   
1870: 69 73 49 6e 74 65 72 6e 44 69 66 66 20 3d 20 66  isInternDiff = f
1880: 69 6e 64 5f 6f 70 74 69 6f 6e 28 22 69 6e 74 65  ind_option("inte
1890: 72 6e 61 6c 22 2c 22 69 22 2c 30 29 21 3d 30 3b  rnal","i",0)!=0;
18a0: 0a 2b 20 20 69 73 46 75 6c 6c 44 69 66 66 20 3d  .+  isFullDiff =
18b0: 20 66 69 6e 64 5f 6f 70 74 69 6f 6e 28 22 66 75   find_option("fu
18c0: 6c 6c 22 2c 20 22 66 22 2c 30 29 21 3d 30 3b 0a  ll", "f",0)!=0;.
18d0: 20 20 20 7a 46 72 6f 6d 20 3d 20 66 69 6e 64 5f     zFrom = find_
18e0: 6f 70 74 69 6f 6e 28 22 66 72 6f 6d 22 2c 20 22  option("from", "
18f0: 72 22 2c 20 31 29 3b 0a 20 20 20 7a 54 6f 20 3d  r", 1);.   zTo =
1900: 20 66 69 6e 64 5f 6f 70 74 69 6f 6e 28 22 74 6f   find_option("to
1910: 22 2c 20 30 2c 20 31 29 3b 0a 20 0a 20 20 20 69  ", 0, 1);. .   i
1920: 66 28 20 7a 54 6f 3d 3d 30 20 29 7b 0a 20 20 20  f( zTo==0 ){.   
1930: 20 20 64 62 5f 6d 75 73 74 5f 62 65 5f 77 69 74    db_must_be_wit
1940: 68 69 6e 5f 74 72 65 65 28 29 3b 0a 40 40 20 2d  hin_tree();.@@ -
1950: 33 38 38 2c 31 31 20 2b 34 36 32 2c 31 31 20 40  388,11 +462,11 @
1960: 40 0a 20 20 20 20 20 20 20 7a 44 69 66 66 43 6d  @.       zDiffCm
1970: 64 20 3d 20 64 62 5f 67 65 74 28 69 73 47 44 69  d = db_get(isGDi
1980: 66 66 20 3f 20 22 67 64 69 66 66 2d 63 6f 6d 6d  ff ? "gdiff-comm
1990: 61 6e 64 22 20 3a 20 22 64 69 66 66 2d 63 6f 6d  and" : "diff-com
19a0: 6d 61 6e 64 22 2c 20 30 29 3b 0a 20 20 20 20 20  mand", 0);.     
19b0: 7d 0a 20 20 20 20 20 69 66 28 20 67 2e 61 72 67  }.     if( g.arg
19c0: 63 3d 3d 33 20 29 7b 0a 20 20 20 20 20 20 20 64  c==3 ){.       d
19d0: 69 66 66 5f 6f 6e 65 5f 61 67 61 69 6e 73 74 5f  iff_one_against_
19e0: 64 69 73 6b 28 7a 46 72 6f 6d 2c 20 7a 44 69 66  disk(zFrom, zDif
19f0: 66 43 6d 64 2c 20 30 29 3b 0a 20 20 20 20 20 7d  fCmd, 0);.     }
1a00: 65 6c 73 65 7b 0a 2d 20 20 20 20 20 20 64 69 66  else{.-      dif
1a10: 66 5f 61 6c 6c 5f 61 67 61 69 6e 73 74 5f 64 69  f_all_against_di
1a20: 73 6b 28 7a 46 72 6f 6d 2c 20 7a 44 69 66 66 43  sk(zFrom, zDiffC
1a30: 6d 64 2c 20 30 29 3b 0a 2b 20 20 20 20 20 20 64  md, 0);.+      d
1a40: 69 66 66 5f 61 6c 6c 5f 61 67 61 69 6e 73 74 5f  iff_all_against_
1a50: 64 69 73 6b 28 7a 46 72 6f 6d 2c 20 7a 44 69 66  disk(zFrom, zDif
1a60: 66 43 6d 64 2c 20 69 73 46 75 6c 6c 44 69 66 66  fCmd, isFullDiff
1a70: 2c 20 30 29 3b 0a 20 20 20 20 20 7d 0a 20 20 20  , 0);.     }.   
1a80: 7d 65 6c 73 65 20 69 66 28 20 7a 46 72 6f 6d 3d  }else if( zFrom=
1a90: 3d 30 20 29 7b 0a 20 20 20 20 20 66 6f 73 73 69  =0 ){.     fossi
1aa0: 6c 5f 66 61 74 61 6c 28 22 6d 75 73 74 20 75 73  l_fatal("must us
1ab0: 65 20 2d 2d 66 72 6f 6d 20 69 66 20 2d 2d 74 6f  e --from if --to
1ac0: 20 69 73 20 70 72 65 73 65 6e 74 22 29 3b 0a 20   is present");. 
1ad0: 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 64 62    }else{.     db
1ae0: 5f 66 69 6e 64 5f 61 6e 64 5f 6f 70 65 6e 5f 72  _find_and_open_r
1af0: 65 70 6f 73 69 74 6f 72 79 28 31 29 3b 0a 0a     epository(1);..