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

Re: My Git Dev Blog - Week 9

From
Atharva Raykar <raykar.ath@gmail.com>
Date
Jul 19, 2021, 08:48 UTC
Message-ID
<6A97A724-4B80-4DDC-B5D2-83F8AD0B27EF@gmail.com>
In-Reply-To
<a8122438-8d8b-9e7d-d66a-dc6eff7a0817@gmail.com>
On 19-Jul-2021, at 08:28, Kaartic Sivaraam <kaartic.sivaraam@gmail.com> wrote:
Show 36 quoted lines
> 
> Hi Atharva and all,
> 
> On 19/07/21 12:49 am, Kaartic Sivaraam wrote:
>> On 18/07/21 5:29 pm, Atharva Raykar wrote:
>>> Passing the superprefix explicitly
>> My gut instinct tells me we could get away without having to go this way but
>> I haven't yet been able to figure out how. How 'prefix', 'super-prefix' and
>> 'recursive-prefix' is still puzzling me. In case anyone has knowledge about
>> this please chime in and enlighten us. It would be very helpful.
>> 
> 
> I just noticed I was short and unhelpful here. To expand on what information would be
> helpful on this respect, here's a snippet of a private e-mail I sent which I've
> tweaked a little to make it relevant for the list audience:
> 
> -- 8< --
>>> ...
>>> 
> 
> I took a look at this. I'm not able to find the exact issue but my gut instinct tells me
> it has something to do with how prefix, super-prefix and recursive-prefix
> are handled before and after the conversion. To be more specific, I'm having doubts
> about whether the following code snippet[4] in shell ...
> 
>    prefix=$(git submodule--helper relative-path "$prefix$sm_path/" "$wt_prefix")
>    wt_prefix=
>    sanitize_submodule_env
>    cd "$sm_path" &&
>    eval cmd_update
> 
> ... has been properly converted to C. Particularly, the fact that recursive calls to
> 'cmd_update' is made in the existing shell implementation in case '--recusive' is
> passed needs to be observed well. This would subsequently result in multiple calls to
> 'cmd_init' with different 'prefix' and 'wt_prefix' values. So, that needs to be
> observed well too.

The whole deal with prefixes confused me initially a lot as well, so I'll try to explain what's going on there first, and then show why I had trouble with it.

The terminology of 'recursive-prefix' was something I borrowed from the update-clone helper[5]. Just to give you a summary of which shell variable maps to which C variable, along with my understanding of what they represent:

| shell      | C                | description                               |
|------------+------------------+-------------------------------------------|
| $prefix    | recursive_prefix | this represents the superproject prefix,  |
|            |                  | ie, the path of the superproject relative |
|            |                  | to the current subproject.                |
|            |                  |                                           |
| $wt_prefix | prefix           | this is the path into the working tree,   |
|            |                  | ie, the path of the directory from the    |
|            |                  | root of the git directory's worktree      |

The display paths that are generated for the error messages require one of these to be non-NULL, but not both[6].

I feel confident the values of the various prefixes are handled properly during the recursion because I setup a new worktree on based master as my "control", and a combination of running with GIT_TRACE2 and printing the values showed me that both of them handle the prefixes identically.

The issue with the subprocess approach[7] seems to be not with the prefixes, but rather with the configuration not being properly read when it is set in the same command invocation.

[5] https://github.com/git/git/blob/75ae10bc75336db031ee58d13c5037b929235912/git-submodule.sh#L536-L550 [6] https://github.com/git/git/blob/75ae10bc75336db031ee58d13c5037b929235912/builtin/submodule--helper.c#L258-L260 [7] https://github.com/tfidfwastaken/git/commits/submodule-helper-update-1a

Show 19 quoted lines
> I have not been able to get a complete picture of this myself. I'll try to take better
> look later and see if I could get anything.
> 
> Note that this could also be me just not being able to get a proper picture of it.
> Just wanted to share it in case others are able to get any ideas or able to think of a
> possible cause.
> 
> [4]: https://github.com/git/git/blob/abb21c7263616f01c5e950861a29279ab21cb02f/git-submodule.sh#L654-L658
> -- >8 --
> 
> I hope that gives a better idea about what kind of information would be helpful.
> Kindly let me know if it doesn't.
> 
> Atharva,
> 
> In the meanwhile, I think you could continue polishing your attempted solution
> and preparing to send it to the list. I'll try to dig more on my gut instinct
> and let you know if I get anything. If you have some free time left after
> polishing your series, you could try digging into it too :)
Sure. Thanks for the time and effort you are putting into this!
> -- 
> Sivaraam
Previous: Kaartic SivaraamNext: Bagas Sanjaya
Message 6 of 8 in “My Git Dev Blog - Week 9”
  1. Atharva RaykarJul 18, 2021
  2. Christian CouderJul 18, 2021
  3. Atharva RaykarJul 19, 2021
  4. Kaartic SivaraamJul 18, 2021
  5. Kaartic SivaraamJul 19, 2021
  6. Atharva RaykarJul 19, 2021
  7. Bagas SanjayaJul 19, 2021
  8. Atharva RaykarJul 19, 2021

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.