git-remote-ext
[gitweb.git] / alias.c
diff --git a/alias.c b/alias.c
index 372b7d809301f9e3e936459e405cd6f2627bd4a9..eb9f08b912b2089d434926fc6083ac5ab90c73bc 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -22,6 +22,13 @@ char *alias_lookup(const char *alias)
        return alias_val;
 }
 
+#define SPLIT_CMDLINE_BAD_ENDING 1
+#define SPLIT_CMDLINE_UNCLOSED_QUOTE 2
+static const char *split_cmdline_errors[] = {
+       "cmdline ends with \\",
+       "unclosed quote"
+};
+
 int split_cmdline(char *cmdline, const char ***argv)
 {
        int src, dst, count = 0, size = 16;
@@ -53,7 +60,7 @@ int split_cmdline(char *cmdline, const char ***argv)
                                if (!c) {
                                        free(*argv);
                                        *argv = NULL;
-                                       return error("cmdline ends with \\");
+                                       return -SPLIT_CMDLINE_BAD_ENDING;
                                }
                        }
                        cmdline[dst++] = c;
@@ -66,7 +73,7 @@ int split_cmdline(char *cmdline, const char ***argv)
        if (quoted) {
                free(*argv);
                *argv = NULL;
-               return error("unclosed quote");
+               return -SPLIT_CMDLINE_UNCLOSED_QUOTE;
        }
 
        ALLOC_GROW(*argv, count+1, size);
@@ -75,3 +82,6 @@ int split_cmdline(char *cmdline, const char ***argv)
        return count;
 }
 
+const char *split_cmdline_strerror(int split_cmdline_errno) {
+       return split_cmdline_errors[-split_cmdline_errno-1];
+}