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

Re: Conversion of 'git submodule' to C: need some help

From
Abhishek Kumar <abhishekkumar8222@gmail.com>
Date
Feb 9, 2020, 15:00 UTC
Message-ID
<CAHk66fte4Rv199jJ8xgrpkzyonyXdhtYzn4fPA7mWPrKA9v2zA@mail.gmail.com>
Greetings Shourya
> 1. What exactly are we aiming in [3]? To replace the function completely
> or to just add some 'repo_submodule_init' functionality?

We are aiming to convert calls to use `repo_submodule_init` instead and remove this function.

If they differ in functionality, implement any changes to `repo_submodule_init` such that code that already uses it runs without any modifications.

> 2. Something I inferred was that functions with names of the pattern 'strbuf_git_*'
> are trying to 'create a path' (are they physically creating the path or just instructing git about them?)

`strbuf_git_*` construct a path to the git directory and append it to the string buffer passed. They are not physically creating folders, just creating a string variable that stores the path. If anything, it returns -1 when the git directory does not exist already. [1]

> while functions of the pattern 'git_*' are trying to check some conditions denoted
> by their function names(for instance  'git_config_rename_section_in_file')?
> Is this inference correct to some extent?

While I cannot talk about whether your inference is correct, `git_config_rename_section_in_file` does not **just** check the condition.

In the case of `remove_path_from_submodules` (where I am guessing you had this doubt), it removes the section from `.gitmodules` and returns a negative value on failure [2]

It's a common idiom in C - Functions with intended side effects return non zero (usually negative) values on failure and zero otherwise. [3]

3. Not sure what you mean. Do elaborate.
4. Yes! Everyone has to begin at some point and learn. Feel free to
ask more questions when in doubt.

Regards Abhishek

[1]: https://github.com/git/git/blob/de93cc14ab7e8db7645d8dbe4fd2603f76d5851f/submodule.c#L2257 [2]: https://github.com/git/git/blob/de93cc14ab7e8db7645d8dbe4fd2603f76d5851f/config.c#L3051 [3]: https://wiki.c2.com/?CeeIdioms

Message 1 of 1 in “Re: Conversion of 'git submodule' to C: need some help”
  1. Abhishek KumarFeb 9, 2020

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.