Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PATCH] get_sha1: support relative path "<obj>:<sth>" syntax

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:50:00

2010/11/11 Junio C Hamano [off-list ref]:
Nguyễn Thái Ngọc Duy  [off-list ref] writes:
quoted
              if (namelen < 3 ||
                  name[2] != ':' ||
-                 name[1] < '0' || '3' < name[1])
+                 name[1] < '0' || '3' < name[1]) {
                      cp = name + 1;
+                     if (startup_info && cp[0] == '.' &&
+                         (cp[1] == '/' || (cp[1] == '.' && cp[2] == '/'))) {
+                             new_path = prefix_path(startup_info->prefix,
+                                                    strlen(startup_info->prefix),
+                                                    cp);
+                             cp = new_path;
+                     }
+             }
What does this new codepath do when we know where the working tree is and
we are outside of the working tree (e.g. we are looking at the index or a
commit in a submodule from above the superproject)?

What should it do?
Prefix is NULL in that case. So no prefixing, git will complain the
given path does not exist (although it should say "./" syntax is not
usable without a worktree).

prefix_path() dies if the resolved path is outside repo. So no, users
can't look up files in superproject from a subproject. I think we need
to define the superproject/subproject relation first. I have
$HOME/.git, but I don't think it's a superproject to any repos inside
my $HOME.
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help