]> git.ipfire.org Git - thirdparty/git.git/blob - rebase.c
reftable: drop stray printf in readwrite_test
[thirdparty/git.git] / rebase.c
1 #include "rebase.h"
2 #include "config.h"
3 #include "gettext.h"
4
5 /*
6 * Parses textual value for pull.rebase, branch.<name>.rebase, etc.
7 * Unrecognised value yields REBASE_INVALID, which traditionally is
8 * treated the same way as REBASE_FALSE.
9 *
10 * The callers that care if (any) rebase is requested should say
11 * if (REBASE_TRUE <= rebase_parse_value(string))
12 *
13 * The callers that want to differenciate an unrecognised value and
14 * false can do so by treating _INVALID and _FALSE differently.
15 */
16 enum rebase_type rebase_parse_value(const char *value)
17 {
18 int v = git_parse_maybe_bool(value);
19
20 if (!v)
21 return REBASE_FALSE;
22 else if (v > 0)
23 return REBASE_TRUE;
24 else if (!strcmp(value, "merges") || !strcmp(value, "m"))
25 return REBASE_MERGES;
26 else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
27 return REBASE_INTERACTIVE;
28 else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
29 error(_("%s: 'preserve' superseded by 'merges'"), value);
30 /*
31 * Please update _git_config() in git-completion.bash when you
32 * add new rebase modes.
33 */
34
35 return REBASE_INVALID;
36 }