]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git.c
use skip_prefix to avoid magic numbers
[thirdparty/git.git] / git.c
diff --git a/git.c b/git.c
index 778057294892d68b3dee58869cf22265223cab83..b2bb09e40a32b129896192dea808aef8c7cd5604 100644 (file)
--- a/git.c
+++ b/git.c
@@ -54,8 +54,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                /*
                 * Check remaining flags.
                 */
-               if (starts_with(cmd, "--exec-path")) {
-                       cmd += 11;
+               if (skip_prefix(cmd, "--exec-path", &cmd)) {
                        if (*cmd == '=')
                                git_set_argv_exec_path(cmd + 1);
                        else {
@@ -92,8 +91,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                                *envchanged = 1;
                        (*argv)++;
                        (*argc)--;
-               } else if (starts_with(cmd, "--git-dir=")) {
-                       setenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);
+               } else if (skip_prefix(cmd, "--git-dir=", &cmd)) {
+                       setenv(GIT_DIR_ENVIRONMENT, cmd, 1);
                        if (envchanged)
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--namespace")) {
@@ -106,8 +105,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                                *envchanged = 1;
                        (*argv)++;
                        (*argc)--;
-               } else if (starts_with(cmd, "--namespace=")) {
-                       setenv(GIT_NAMESPACE_ENVIRONMENT, cmd + 12, 1);
+               } else if (skip_prefix(cmd, "--namespace=", &cmd)) {
+                       setenv(GIT_NAMESPACE_ENVIRONMENT, cmd, 1);
                        if (envchanged)
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--work-tree")) {
@@ -120,8 +119,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                                *envchanged = 1;
                        (*argv)++;
                        (*argc)--;
-               } else if (starts_with(cmd, "--work-tree=")) {
-                       setenv(GIT_WORK_TREE_ENVIRONMENT, cmd + 12, 1);
+               } else if (skip_prefix(cmd, "--work-tree=", &cmd)) {
+                       setenv(GIT_WORK_TREE_ENVIRONMENT, cmd, 1);
                        if (envchanged)
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--bare")) {
@@ -578,8 +577,7 @@ int main(int argc, char **av)
         * So we just directly call the builtin handler, and die if
         * that one cannot handle it.
         */
-       if (starts_with(cmd, "git-")) {
-               cmd += 4;
+       if (skip_prefix(cmd, "git-", &cmd)) {
                argv[0] = cmd;
                handle_builtin(argc, argv);
                die("cannot handle %s as a builtin", cmd);