3 static const char *alias_key;
4 static char *alias_val;
6 static int alias_lookup_cb(const char *k, const char *v, void *cb)
8 if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) {
10 return config_error_nonbool(k);
11 alias_val = xstrdup(v);
17 char *alias_lookup(const char *alias)
21 git_config(alias_lookup_cb, NULL);
25 int split_cmdline(char *cmdline, const char ***argv)
27 int src, dst, count = 0, size = 16;
30 *argv = xmalloc(sizeof(char *) * size);
32 /* split alias_string */
33 (*argv)[count++] = cmdline;
34 for (src = dst = 0; cmdline[src];) {
35 char c = cmdline[src];
36 if (!quoted && isspace(c)) {
39 && isspace(cmdline[src]))
41 ALLOC_GROW(*argv, count+1, size);
42 (*argv)[count++] = cmdline + dst;
43 } else if (!quoted && (c == '\'' || c == '"')) {
46 } else if (c == quoted) {
50 if (c == '\\' && quoted != '\'') {
56 return error("cmdline ends with \\");
69 return error("unclosed quote");
72 ALLOC_GROW(*argv, count+1, size);
73 (*argv)[count] = NULL;