revision traversal: retire BOUNDARY_SHOW
[gitweb.git] / builtin-rev-parse.c
index aca4a3603283a257f7621934103c85d5c0c31390..37addb25fafbedba9bad6e99746ee65bacdee7d3 100644 (file)
 #define DO_NONFLAGS    8
 static int filter = ~0;
 
-static const char *def = NULL;
+static const char *def;
 
 #define NORMAL 0
 #define REVERSED 1
 static int show_type = NORMAL;
-static int symbolic = 0;
-static int abbrev = 0;
-static int output_sq = 0;
+static int symbolic;
+static int abbrev;
+static int output_sq;
 
-static int revs_count = 0;
+static int revs_count;
 
 /*
  * Some arguments are relevant "revision" arguments,
@@ -137,7 +137,7 @@ static void show_default(void)
        }
 }
 
-static int show_reference(const char *refname, const unsigned char *sha1)
+static int show_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
 {
        show_rev(NORMAL, sha1, refname);
        return 0;
@@ -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;
@@ -299,19 +299,19 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                continue;
                        }
                        if (!strcmp(arg, "--all")) {
-                               for_each_ref(show_reference);
+                               for_each_ref(show_reference, NULL);
                                continue;
                        }
                        if (!strcmp(arg, "--branches")) {
-                               for_each_branch_ref(show_reference);
+                               for_each_branch_ref(show_reference, NULL);
                                continue;
                        }
                        if (!strcmp(arg, "--tags")) {
-                               for_each_tag_ref(show_reference);
+                               for_each_tag_ref(show_reference, NULL);
                                continue;
                        }
                        if (!strcmp(arg, "--remotes")) {
-                               for_each_remote_ref(show_reference);
+                               for_each_remote_ref(show_reference, NULL);
                                continue;
                        }
                        if (!strcmp(arg, "--show-prefix")) {
@@ -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;
                        }