git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Nov 11, 2010, 01:30 UTC
Message-ID
<AANLkTimxR1YV+D2HBHUr8bCbrT7XyHfKoMN71raUZ3Jx@mail.gmail.com>
In-Reply-To
<7veiatht1b.fsf@alter.siamese.dyndns.org>
2010/11/11 Junio C Hamano <gitster@pobox.com>:
Show 21 quoted lines
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>
>>               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
Previous: Junio C HamanoNext: Junio C Hamano
Message 15 of 21 in “Re: [RFC] Using gitrevisions :/search style with other operators”
  1. Yann DirsonNov 9, 2010
  2. Kevin BallardNov 9, 2010
  3. Yann DirsonNov 9, 2010
  4. Junio C HamanoNov 10, 2010
  5. Kevin BallardNov 10, 2010
  6. Yann DirsonNov 10, 2010
  7. Kevin BallardNov 10, 2010
  8. Yann DirsonNov 10, 2010
  9. Jakub NarebskiNov 10, 2010
  10. get_sha1: support relative path "<obj>:<sth>" syntaxNguyễn Thái Ngọc Duy, Nov 10, 2010
  11. Matthieu MoyNov 10, 2010
  12. Jonathan NiederNov 10, 2010
  13. Nguyen Thai Ngoc DuyNov 11, 2010
  14. Junio C HamanoNov 10, 2010
  15. Nguyen Thai Ngoc DuyNov 11, 2010
  16. Junio C HamanoDec 9, 2010
  17. Junio C HamanoDec 9, 2010
  18. Nguyen Thai Ngoc DuyDec 10, 2010
  19. Junio C HamanoNov 10, 2010
  20. Jakub NarebskiNov 10, 2010
  21. Jeff KingNov 9, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.