3 char *alias_lookup(const char *alias)
6 struct strbuf key = STRBUF_INIT;
7 strbuf_addf(&key, "alias.%s", alias);
8 git_config_get_string(key.buf, &v);
13 #define SPLIT_CMDLINE_BAD_ENDING 1
14 #define SPLIT_CMDLINE_UNCLOSED_QUOTE 2
15 static const char *split_cmdline_errors[] = {
16 "cmdline ends with \\",
20 int split_cmdline(char *cmdline, const char ***argv)
22 int src, dst, count = 0, size = 16;
25 *argv = xmalloc(sizeof(**argv) * size);
27 /* split alias_string */
28 (*argv)[count++] = cmdline;
29 for (src = dst = 0; cmdline[src];) {
30 char c = cmdline[src];
31 if (!quoted && isspace(c)) {
34 && isspace(cmdline[src]))
36 ALLOC_GROW(*argv, count + 1, size);
37 (*argv)[count++] = cmdline + dst;
38 } else if (!quoted && (c == '\'' || c == '"')) {
41 } else if (c == quoted) {
45 if (c == '\\' && quoted != '\'') {
51 return -SPLIT_CMDLINE_BAD_ENDING;
64 return -SPLIT_CMDLINE_UNCLOSED_QUOTE;
67 ALLOC_GROW(*argv, count + 1, size);
68 (*argv)[count] = NULL;
73 const char *split_cmdline_strerror(int split_cmdline_errno)
75 return split_cmdline_errors[-split_cmdline_errno - 1];