show_reference(): rewrite to take an object_id argument
[gitweb.git] / builtin / rev-parse.c
index 95328b80d930260915ad86a30a21ecd3c1b7d1f4..b6232390a649a74f9c188a6f9abe8ab9651191a1 100644 (file)
@@ -190,17 +190,17 @@ static int show_default(void)
        return 0;
 }
 
-static int show_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
+static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
 {
        if (ref_excluded(ref_excludes, refname))
                return 0;
-       show_rev(NORMAL, sha1, refname);
+       show_rev(NORMAL, oid->hash, refname);
        return 0;
 }
 
-static int anti_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
+static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
 {
-       show_rev(REVERSED, sha1, refname);
+       show_rev(REVERSED, oid->hash, refname);
        return 0;
 }
 
@@ -358,7 +358,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 {
        static int keep_dashdash = 0, stop_at_non_option = 0;
        static char const * const parseopt_usage[] = {
-               N_("git rev-parse --parseopt [options] -- [<args>...]"),
+               N_("git rev-parse --parseopt [<options>] -- [<args>...]"),
                NULL
        };
        static struct option parseopt_opts[] = {
@@ -496,9 +496,9 @@ static void die_no_single_rev(int quiet)
 }
 
 static const char builtin_rev_parse_usage[] =
-N_("git rev-parse --parseopt [options] -- [<args>...]\n"
+N_("git rev-parse --parseopt [<options>] -- [<args>...]\n"
    "   or: git rev-parse --sq-quote [<arg>...]\n"
-   "   or: git rev-parse [options] [<arg>...]\n"
+   "   or: git rev-parse [<options>] [<arg>...]\n"
    "\n"
    "Run \"git rev-parse --parseopt -h\" for more information on the first usage.");
 
@@ -533,6 +533,13 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
 
+               if (!strcmp(arg, "--git-path")) {
+                       if (!argv[i + 1])
+                               die("--git-path requires an argument");
+                       puts(git_path("%s", argv[i + 1]));
+                       i++;
+                       continue;
+               }
                if (as_is) {
                        if (show_file(arg, output_prefix) && as_is < 2)
                                verify_filename(prefix, arg, 0);
@@ -755,6 +762,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                free(cwd);
                                continue;
                        }
+                       if (!strcmp(arg, "--git-common-dir")) {
+                               puts(get_git_common_dir());
+                               continue;
+                       }
                        if (!strcmp(arg, "--resolve-git-dir")) {
                                const char *gitdir = argv[++i];
                                if (!gitdir)