3 char *alias_lookup(const char *alias
)
6 struct strbuf key
= STRBUF_INIT
;
7 strbuf_addf(&key
, "alias.%s", alias
);
8 if (git_config_key_is_valid(key
.buf
))
9 git_config_get_string(key
.buf
, &v
);
14 #define SPLIT_CMDLINE_BAD_ENDING 1
15 #define SPLIT_CMDLINE_UNCLOSED_QUOTE 2
16 static const char *split_cmdline_errors
[] = {
17 "cmdline ends with \\",
21 int split_cmdline(char *cmdline
, const char ***argv
)
23 int src
, dst
, count
= 0, size
= 16;
26 ALLOC_ARRAY(*argv
, size
);
28 /* split alias_string */
29 (*argv
)[count
++] = cmdline
;
30 for (src
= dst
= 0; cmdline
[src
];) {
31 char c
= cmdline
[src
];
32 if (!quoted
&& isspace(c
)) {
35 && isspace(cmdline
[src
]))
37 ALLOC_GROW(*argv
, count
+ 1, size
);
38 (*argv
)[count
++] = cmdline
+ dst
;
39 } else if (!quoted
&& (c
== '\'' || c
== '"')) {
42 } else if (c
== quoted
) {
46 if (c
== '\\' && quoted
!= '\'') {
52 return -SPLIT_CMDLINE_BAD_ENDING
;
65 return -SPLIT_CMDLINE_UNCLOSED_QUOTE
;
68 ALLOC_GROW(*argv
, count
+ 1, size
);
69 (*argv
)[count
] = NULL
;
74 const char *split_cmdline_strerror(int split_cmdline_errno
)
76 return split_cmdline_errors
[-split_cmdline_errno
- 1];