Browse Source

Properly return -1 on unresolved conflict

Andrew Young 7 years ago
parent
commit
d19a3ff027
4 changed files with 13 additions and 3 deletions
  1. 2 0
      src/main.c
  2. 9 3
      src/print.c
  3. 1 0
      src/print_ctxt.c
  4. 1 0
      src/print_ctxt.h

+ 2 - 0
src/main.c

@@ -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

+ 9 - 3
src/print.c

@@ -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 */

+ 1 - 0
src/print_ctxt.c

@@ -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;
 }
 

+ 1 - 0
src/print_ctxt.h

@@ -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;
 
 /**