Merge branch 'rt/completion-tag'
[gitweb.git] / builtin / rev-parse.c
index d85e08cc9cc22ee307470dbeb12fdd8d1eea655b..35d3c43ed656bf28b78501426f4502c0dff1e7b0 100644 (file)
@@ -508,7 +508,9 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
        int has_dashdash = 0;
        int output_prefix = 0;
        unsigned char sha1[20];
+       unsigned int flags = 0;
        const char *name = NULL;
+       struct object_context unused;
 
        if (argc > 1 && !strcmp("--parseopt", argv[1]))
                return cmd_parseopt(argc - 1, argv + 1, prefix);
@@ -596,6 +598,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                        }
                        if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) {
                                quiet = 1;
+                               flags |= GET_SHA1_QUIETLY;
                                continue;
                        }
                        if (!strcmp(arg, "--short") ||
@@ -736,7 +739,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                        }
                        if (!strcmp(arg, "--git-dir")) {
                                const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
-                               static char cwd[PATH_MAX];
+                               char *cwd;
                                int len;
                                if (gitdir) {
                                        puts(gitdir);
@@ -746,10 +749,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                        puts(".git");
                                        continue;
                                }
-                               if (!getcwd(cwd, PATH_MAX))
-                                       die_errno("unable to get current working directory");
+                               cwd = xgetcwd();
                                len = strlen(cwd);
                                printf("%s%s.git\n", cwd, len && cwd[len-1] != '/' ? "/" : "");
+                               free(cwd);
                                continue;
                        }
                        if (!strcmp(arg, "--resolve-git-dir")) {
@@ -818,7 +821,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                        name++;
                        type = REVERSED;
                }
-               if (!get_sha1(name, sha1)) {
+               if (!get_sha1_with_context(name, flags, sha1, &unused)) {
                        if (verify)
                                revs_count++;
                        else