rebase.c 1.0 KB

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