Code

Don't smash stack when $GIT_ALTERNATE_OBJECT_DIRECTORIES is too long
[git.git] / builtin-rev-parse.c
index 3b716fba133ae2f0375ef73d6a50a4d93112b5e4..37addb25fafbedba9bad6e99746ee65bacdee7d3 100644 (file)
@@ -233,7 +233,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                        }
                        continue;
                }
-               if (!strncmp(arg,"-n",2)) {
+               if (!prefixcmp(arg, "-n")) {
                        if ((filter & DO_FLAGS) && (filter & DO_REVS))
                                show(arg);
                        continue;
@@ -274,7 +274,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                continue;
                        }
                        if (!strcmp(arg, "--short") ||
-                           !strncmp(arg, "--short=", 8)) {
+                           !prefixcmp(arg, "--short=")) {
                                filter &= ~(DO_FLAGS|DO_NOREV);
                                verify = 1;
                                abbrev = DEFAULT_ABBREV;
@@ -347,19 +347,24 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                printf("%s/.git\n", cwd);
                                continue;
                        }
-                       if (!strncmp(arg, "--since=", 8)) {
+                       if (!strcmp(arg, "--is-inside-git-dir")) {
+                               printf("%s\n", is_inside_git_dir() ? "true"
+                                               : "false");
+                               continue;
+                       }
+                       if (!prefixcmp(arg, "--since=")) {
                                show_datestring("--max-age=", arg+8);
                                continue;
                        }
-                       if (!strncmp(arg, "--after=", 8)) {
+                       if (!prefixcmp(arg, "--after=")) {
                                show_datestring("--max-age=", arg+8);
                                continue;
                        }
-                       if (!strncmp(arg, "--before=", 9)) {
+                       if (!prefixcmp(arg, "--before=")) {
                                show_datestring("--min-age=", arg+9);
                                continue;
                        }
-                       if (!strncmp(arg, "--until=", 8)) {
+                       if (!prefixcmp(arg, "--until=")) {
                                show_datestring("--min-age=", arg+8);
                                continue;
                        }