blob: 6775cddb28434d0780cb483357476f4783e1f596 [file] [log] [blame]
Bert Wesarg88f85762020-01-27 08:04:27 +01001#include "rebase.h"
2#include "config.h"
Johannes Schindelin52f1e822021-09-07 21:05:05 +00003#include "gettext.h"
Bert Wesarg88f85762020-01-27 08:04:27 +01004
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 */
16enum 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;
Bert Wesarg88f85762020-01-27 08:04:27 +010024 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;
Johannes Schindelin52f1e822021-09-07 21:05:05 +000028 else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
29 error(_("%s: 'preserve' superseded by 'merges'"), value);
Bert Wesarg88f85762020-01-27 08:04:27 +010030 /*
31 * Please update _git_config() in git-completion.bash when you
32 * add new rebase modes.
33 */
34
35 return REBASE_INVALID;
36}