Properly return -1 on unresolved conflict
authorAndrew Young <youngar17@gmail.com>
Mon, 13 Aug 2012 15:30:22 +0000 (11:30 -0400)
committerAndrew Young <youngar17@gmail.com>
Mon, 13 Aug 2012 15:30:22 +0000 (11:30 -0400)
src/main.c
src/print.c
src/print_ctxt.c
src/print_ctxt.h

index 70956cd..33ae962 100755 (executable)
@@ -147,6 +147,8 @@ main (int argc, char *argv[])
              debug_msg (MAIN, 3, "Printing\n\n");
              org_document_print (anc, &print_ctxt, out);
 
+              exit_status = (print_ctxt.conflict_occurred ? -1 : exit_status);
+
              fclose (rem_file);
            }
          else
index 351ce17..ec6a9ab 100644 (file)
@@ -3,9 +3,9 @@
 #include "print_ctxt.h"
 #include "print.h"
 
-static const char *start_mark  = ">>> ";
-static const char *middle_mark = "=== ";
-static const char *end_mark    = "<<< ";
+static const char *start_mark  = ">>>>>>> ";
+static const char *middle_mark = "======= ";
+static const char *end_mark    = "<<<<<<< ";
 
 void
 enter_structural_conflict (print_ctxt *ctxt, conflict_state state,
@@ -21,6 +21,9 @@ enter_structural_conflict (print_ctxt *ctxt, conflict_state state,
   else
     return;
 
+  if (state != no_conflict)
+    ctxt->conflict_occurred = true;
+
   while (ctxt->structure_conflict != state )
     {
       /*conflict wrap up */
@@ -64,6 +67,9 @@ enter_content_conflict (print_ctxt *ctxt, conflict_state state,
   if (ctxt->content_conflict == state)
     return;
 
+  if (state != no_conflict)
+    ctxt->conflict_occurred = true;
+
   while ( ctxt->content_conflict != state  )
     {
       /*conflict wrap up */
index 2deb7ce..7688dfb 100644 (file)
@@ -27,6 +27,7 @@ print_ctxt_init (print_ctxt *ctxt)
   ctxt->nested_conflicts = no_conflict;
   ctxt->structure_conflict = no_conflict;
   ctxt->content_conflict = no_conflict;
+  ctxt->conflict_occurred = false;
   return;
 }
 
index 53ac134..5d9b821 100644 (file)
@@ -23,6 +23,7 @@ typedef struct print_ctxt
   bool           nested_conflicts;   /*< if there are nested conflicts        */
   conflict_state structure_conflict; /*< the current state of conflicts       */
   conflict_state content_conflict;   /*< the current state of conflicts       */
+  bool           conflict_occurred;   /* IF a conflict occured                 */
 } print_ctxt;
 
 /**