Imported Upstream version 2.27.0
[platform/upstream/git.git] / builtin / rev-parse.c
index 7a00da8..669dd2f 100644 (file)
@@ -16,6 +16,7 @@
 #include "split-index.h"
 #include "submodule.h"
 #include "commit-reach.h"
+#include "shallow.h"
 
 #define DO_REVS                1
 #define DO_NOREV       2
@@ -808,9 +809,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                continue;
                        }
                        if (!strcmp(arg, "--show-superproject-working-tree")) {
-                               const char *superproject = get_superproject_working_tree();
-                               if (superproject)
-                                       puts(superproject);
+                               struct strbuf superproject = STRBUF_INIT;
+                               if (get_superproject_working_tree(&superproject))
+                                       puts(superproject.buf);
+                               strbuf_release(&superproject);
                                continue;
                        }
                        if (!strcmp(arg, "--show-prefix")) {
@@ -857,7 +859,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                        if (!gitdir && !prefix)
                                                gitdir = ".git";
                                        if (gitdir) {
-                                               puts(real_path(gitdir));
+                                               struct strbuf realpath = STRBUF_INIT;
+                                               strbuf_realpath(&realpath, gitdir, 1);
+                                               puts(realpath.buf);
+                                               strbuf_release(&realpath);
                                                continue;
                                        }
                                }