blob: 17a570f1ff97fab8e789d2960ae54894b1c42a80 [file] [log] [blame]
Elijah Newren8bff5ca2023-02-24 00:09:20 +00001#include "git-compat-util.h"
Bert Wesarg88f85762020-01-27 08:04:27 +01002#include "rebase.h"
3#include "config.h"
Johannes Schindelin52f1e822021-09-07 21:05:05 +00004#include "gettext.h"
Bert Wesarg88f85762020-01-27 08:04:27 +01005
6/*
7 * Parses textual value for pull.rebase, branch.<name>.rebase, etc.
8 * Unrecognised value yields REBASE_INVALID, which traditionally is
9 * treated the same way as REBASE_FALSE.
10 *
11 * The callers that care if (any) rebase is requested should say
12 * if (REBASE_TRUE <= rebase_parse_value(string))
13 *
14 * The callers that want to differenciate an unrecognised value and
15 * false can do so by treating _INVALID and _FALSE differently.
16 */
17enum rebase_type rebase_parse_value(const char *value)
18{
19 int v = git_parse_maybe_bool(value);
20
21 if (!v)
22 return REBASE_FALSE;
23 else if (v > 0)
24 return REBASE_TRUE;
Bert Wesarg88f85762020-01-27 08:04:27 +010025 else if (!strcmp(value, "merges") || !strcmp(value, "m"))
26 return REBASE_MERGES;
27 else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
28 return REBASE_INTERACTIVE;
Johannes Schindelin52f1e822021-09-07 21:05:05 +000029 else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
30 error(_("%s: 'preserve' superseded by 'merges'"), value);
Bert Wesarg88f85762020-01-27 08:04:27 +010031 /*
32 * Please update _git_config() in git-completion.bash when you
33 * add new rebase modes.
34 */
35
36 return REBASE_INVALID;
37}