Index: trunk/ippTools/src/difftool.c
===================================================================
--- trunk/ippTools/src/difftool.c	(revision 27007)
+++ trunk/ippTools/src/difftool.c	(revision 27020)
@@ -136,5 +136,6 @@
     PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false);
     PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false);
-    PXOPT_LOOKUP_STR(reduction, config->args, "-rset_eduction", false, false);
+    PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false);
+    PXOPT_LOOKUP_S16(diff_mode, config->args, "-set_diff_mode", false, false);
     PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false);
 
@@ -157,4 +158,5 @@
             exposure,
             false,
+	    diff_mode,
             note
     );
@@ -990,5 +992,19 @@
         return false;
     }
-
+    psS16 diff_mode = 0;
+    if ((input_warp_id != PS_MAX_S64) && (template_warp_id != PS_MAX_S64)) {
+      diff_mode = 1;
+    }
+    else if ((input_warp_id != PS_MAX_S64) && (template_stack_id != PS_MAX_S64)) {
+      diff_mode = 2;
+    }
+    else if ((input_stack_id != PS_MAX_S64) && (template_warp_id != PS_MAX_S64)) {
+      diff_mode = 3;
+    }
+    else if ((input_stack_id != PS_MAX_S64) && (template_stack_id != PS_MAX_S64)) {
+      diff_mode = 4;
+    }
+    
+    
     // default
     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
@@ -1009,4 +1025,5 @@
             false,
             0,       // magicked
+	    diff_mode, // diff_mode
             note
     );
@@ -1114,5 +1131,5 @@
 
     psArray *list = psArrayAllocEmpty(16); // List of runs, to print
-
+    // Populated Run will generate the diff_mode value
     if (!populatedrun(list, workdir, skycell_id, tess_id, label, data_group ? data_group : label, dist_group, reduction, note,
                       input_warp_id ? input_warp_id : PS_MAX_S64,
@@ -1419,4 +1436,5 @@
                 true,                   // exposure
                 0,       // magicked
+		2,       // diff_mode for warp-stack difference
                 note
         );
@@ -1760,6 +1778,19 @@
         }
 
-        diffRunRow *run = diffRunRowAlloc(0, "reg", workdir, label, data_group ? data_group : label, dist_group, reduction, NULL, registered,
-                                          tess_id, true, true, false, note); // Run to insert
+        diffRunRow *run = diffRunRowAlloc(0,
+					  "reg",
+					  workdir,
+					  label,
+					  data_group ? data_group : label,
+					  dist_group,
+					  reduction,
+					  NULL,  // dvodb
+					  registered,
+                                          tess_id,
+					  true,  // bothways
+					  true,  // exposure
+					  false, // magicked
+					  1,     // diff_mode for warp-warp diff
+					  note); // Run to insert
         if (!diffRunInsertObject(config->dbh, run)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
@@ -2042,4 +2073,5 @@
                                       false,                 // exposure
                                       0,       // magicked
+				      4,       // diff_mode
                                       note
                                       );
