mirror of
https://github.com/git/git.git
synced 2024-11-24 10:26:17 +08:00
88f8576eda
When 46af44b07d
(pull --rebase=<type>: allow single-letter abbreviations
for the type, 2018-08-04) landed in Git, it had the side effect that
not only 'pull --rebase=<type>' accepted the single-letter abbreviations
but also the 'pull.rebase' and 'branch.<name>.rebase' configurations.
However, 'git remote rename' did not honor these single-letter
abbreviations when reading the 'branch.*.rebase' configurations.
We now document the single-letter abbreviations and both code places
share a common function to parse the values of 'git pull --rebase=*',
'pull.rebase', and 'branches.*.rebase'.
The only functional change is the handling of the `branch_info::rebase`
value. Before it was an unsigned enum, thus the truth value could be
checked with `branch_info::rebase != 0`. But `enum rebase_type` is
signed, thus the truth value must now be checked with
`branch_info::rebase >= REBASE_TRUE`
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
36 lines
1.0 KiB
C
36 lines
1.0 KiB
C
#include "rebase.h"
|
|
#include "config.h"
|
|
|
|
/*
|
|
* Parses textual value for pull.rebase, branch.<name>.rebase, etc.
|
|
* Unrecognised value yields REBASE_INVALID, which traditionally is
|
|
* treated the same way as REBASE_FALSE.
|
|
*
|
|
* The callers that care if (any) rebase is requested should say
|
|
* if (REBASE_TRUE <= rebase_parse_value(string))
|
|
*
|
|
* The callers that want to differenciate an unrecognised value and
|
|
* false can do so by treating _INVALID and _FALSE differently.
|
|
*/
|
|
enum rebase_type rebase_parse_value(const char *value)
|
|
{
|
|
int v = git_parse_maybe_bool(value);
|
|
|
|
if (!v)
|
|
return REBASE_FALSE;
|
|
else if (v > 0)
|
|
return REBASE_TRUE;
|
|
else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
|
|
return REBASE_PRESERVE;
|
|
else if (!strcmp(value, "merges") || !strcmp(value, "m"))
|
|
return REBASE_MERGES;
|
|
else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
|
|
return REBASE_INTERACTIVE;
|
|
/*
|
|
* Please update _git_config() in git-completion.bash when you
|
|
* add new rebase modes.
|
|
*/
|
|
|
|
return REBASE_INVALID;
|
|
}
|