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

Re: [PATCH v9 0/8] submodule show inline diff

From
Jacob Keller <jacob.keller@gmail.com>
Date
Aug 20, 2016, 06:16 UTC
Message-ID
<CA+P7+xoazoY49cXMghVQmCd=X-aEj6xCTqQqr69zciFZAqmw_Q@mail.gmail.com>
In-Reply-To
<CAGZ79kZqkHO58kUvP772jfTUgyYXxYuDkgGB1sOTYYQ6nLCP4A@mail.gmail.com>
On Fri, Aug 19, 2016 at 5:02 PM, Stefan Beller <sbeller@google.com> wrote:
Show 12 quoted lines
> On Fri, Aug 19, 2016 at 4:34 PM, Jacob Keller <jacob.e.keller@intel.com> wrote:
>> -               strbuf_git_path(buf, "%s/%s", "modules", path);
>> +               /*
>> +                * Lookup the submodule name from the config. If that fails
>> +                * fall back to assuming the path is the name.
>> +                */
>> +               submodule_config = submodule_from_path(null_sha1, path);
>
> In case you need to reroll: I'd got with just "sub" as the name for
> the config object
> (that seems to be used all the time and is shorter)
>
Sure.
Show 8 quoted lines
>
>> +               if (submodule_config)
>> +                       strbuf_git_path(buf, "%s/%s", "modules",
>> +                                       submodule_config->name);
>> +               else
>
> I do not think we want to assume the path as the name for the fallback, though.
>

I couldn't think of anything better to do.... There is no error return flow, so just... leave it as is maybe?

Show 5 quoted lines
> If `submodule_config == NULL` then
> a) the path/name doesn't exist in the given version.
>     (If null_sha1 is given, HEAD + working tree is assumed, whereas
>     you could also check for a specific commit of the superproject
>     with another sha1)

I can't check for a specific version here because there is no mechanism to pass in the value we'd check it in... Maybe I need a separate function for that to check the specific sha1 instead of using nullsha1? But.. no I don't think that makes sense, we use the current working tree to get the submodule and then lookup old references in it... but if we checked an old tree it might be in the wrong path which does us no good because the name no longer matches? Hmmm

Show 11 quoted lines
>
> b) or the submodule config cache was not initialized
>    (missing call to gitmodules_config())
>
> c) There is no c) [at least I never came across another reason for a
> NULL return here]
>
> Using the path as the fallback is errorprone (e.g. to b. in the future
> and then you get the wrong submodule repository which is shaded by
> assuming the path and it is hard to debug later or write forward looking
> tests for that now)

Sure, but if it doesn't exist we just fail.. so what should I put in the string? just leave it empty? The function doesn't have an error return at the moment.

>
> Thanks,
> Stefan
Previous: Stefan BellerNext: Stefan Beller
Message 11 of 12 in “submodule show inline diff”
  1. 0/8 submodule show inline diffJacob Keller, Aug 19, 2016
  2. 1/8 cache: add empty_tree_oid object and helper functionJacob Keller, Aug 19, 2016
  3. 5/8 submodule: allow add_submodule_odb to work even if path is not checked outJacob Keller, Aug 19, 2016
  4. 4/8 diff: prepare for additional submodule formatsJacob Keller, Aug 19, 2016
  5. 2/8 diff.c: remove output_prefix_length fieldJacob Keller, Aug 19, 2016
  6. 6/8 submodule: convert show_submodule_summary to use struct object_id *Jacob Keller, Aug 19, 2016
  7. 3/8 graph: add support for --line-prefix on all graph-aware outputJacob Keller, Aug 19, 2016
  8. 8/8 diff: teach diff to display submodule difference with an inline diffJacob Keller, Aug 19, 2016
  9. 7/8 submodule: refactor show_submodule_summary with helper functionJacob Keller, Aug 19, 2016
  10. Stefan BellerAug 20, 2016
  11. Jacob KellerAug 20, 2016
  12. Stefan BellerAug 22, 2016

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.