added resolve-conflicts and delete-conflicts to help text and fixed crash with unknown cmd options

Fri, 18 Mar 2016 12:38:30 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 18 Mar 2016 12:38:30 +0100
changeset 219
9792cfe63b80
parent 218
5f1f7602cf77
child 220
f1b3873a6525

added resolve-conflicts and delete-conflicts to help text and fixed crash with unknown cmd options

dav/optparser.c file | annotate | diff | comparison | revisions
dav/sopt.c file | annotate | diff | comparison | revisions
dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/optparser.c	Thu Mar 17 22:02:15 2016 +0100
+++ b/dav/optparser.c	Fri Mar 18 12:38:30 2016 +0100
@@ -33,9 +33,11 @@
 #include "optparser.h"
 
 void cmd_args_free(CmdArgs *args) {
-    ucx_map_free(args->options);
-    free(args->argv);
-    free(args);
+    if(args) {
+        ucx_map_free(args->options);
+        free(args->argv);
+        free(args);
+    }
 }
 
 CmdArgs* cmd_parse_args(int argc, char **argv) {
@@ -55,7 +57,7 @@
             for(int c=1;c<len;c++) {
                 switch(arg[c]) {
                     default: {
-                        fprintf(stderr, "Unknown option -%c", arg[c]);
+                        fprintf(stderr, "Unknown option -%c\n\n", arg[c]);
                         cmd_args_free(a);
                         return NULL;
                     }
--- a/dav/sopt.c	Thu Mar 17 22:02:15 2016 +0100
+++ b/dav/sopt.c	Fri Mar 18 12:38:30 2016 +0100
@@ -33,8 +33,11 @@
 #include "optparser.h"
 
 void cmd_args_free(CmdArgs *args) {
-    ucx_map_free(args->options);
-    free(args->argv);
+    if(args) {
+        ucx_map_free(args->options);
+        free(args->argv);
+        free(args);
+    }
 }
 
 CmdArgs* cmd_parse_args(int argc, char **argv) {
@@ -54,7 +57,7 @@
             for(int c=1;c<len;c++) {
                 switch(arg[c]) {
                     default: {
-                        fprintf(stderr, "Unknown option -%c", arg[c]);
+                        fprintf(stderr, "Unknown option -%c\n\n", arg[c]);
                         cmd_args_free(a);
                         return NULL;
                     }
--- a/dav/sync.c	Thu Mar 17 22:02:15 2016 +0100
+++ b/dav/sync.c	Fri Mar 18 12:38:30 2016 +0100
@@ -122,8 +122,9 @@
     
     fprintf(stderr, "Commands:\n");
     fprintf(stderr, "        pull [-c] <directory>\n");
-    //fprintf(stderr, "        push [-r] <directory>\n\n");
-    fprintf(stderr, "        push <directory>\n");
+    fprintf(stderr, "        push [-c] <directory>\n");
+    fprintf(stderr, "        resolve-conflicts <directory>\n");
+    fprintf(stderr, "        delete-conflicts <directory>\n");
     fprintf(stderr, "        trash-info <directory>\n");
     fprintf(stderr, "        empty-trash <directory>\n\n");
     
@@ -679,8 +680,9 @@
     int sync_error = 0;
     
     // upload all changed files
-    UcxList *resources = cmd_getoption(a, "read") ?
-            read_changes(dir, db) : local_scan(dir, db);
+    //UcxList *resources = cmd_getoption(a, "read") ?
+    //        read_changes(dir, db) : local_scan(dir, db);
+    UcxList *resources = local_scan(dir, db);
     
     UcxMap *lclres = ucx_map_new(db->resources->count);
     int ret = 0;

mercurial