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

Re: [PATCH v10 0/9] submodule inline diff format

From
Jacob Keller <jacob.keller@gmail.com>
Date
Aug 25, 2016, 22:46 UTC
Message-ID
<CA+P7+xqDRD4akNShqxs4D2dDUBK0E5Eyp2Y3-8xK6wEb5gCU6w@mail.gmail.com>
In-Reply-To
<xmqqr39cjwxx.fsf@gitster.mtv.corp.google.com>
On Thu, Aug 25, 2016 at 3:38 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 19 quoted lines
> Jacob Keller <jacob.keller@gmail.com> writes:
>
>> So we should support the gitlink to a repository stored at <path>
>> without stuff inside the .git/modules, and we should support submodule
>> gitlinks with a proper .gitmodules setup. I don't think we should
>> die() but we should error properly so I will introduce a _gently()
>> variant of these functions, and die properly in the regular flow.
>
> Because "git diff [--cached] [<tree-ish>]" in the top-level is
> driven by a gitlink in the index, immediately after adding a new
> submodule to the index but before describing it in .gitmodules you
> might not have a name (and you know in that case the path will
> become the name when adding it to .gitmodules).  Also a gitlink in
> the index may correspond to a submodule the user of the top-level is
> not interested in, so there may not be anything in .git/modules/
> that corresponds to it.  In these cases, I suspect that you do not
> want to die, but you can just tell the user "I do not have enough
> information to tell you a useful story yet".
>

Right. submodule_from_path() fails to find a config. I don't think die() is right here, because there is no easy way to make this into a gently() variant.... I can still do it if we think a die() is worthwhile otherwise for the other callers of do_submodule_path...

However, I think the safest thing is to just:

a) read_gitfile on <path>/.git b) if read_gitfile succeeds, use it's contents, otherwise use <path>/.git for next steps c) check if the resulting file is a git directory, we're fine.. we found a gitdir, so stop. d) otherwise, empty the buffer, then lookup submodules e) when submodules lookup succeeds.. see if we found a name. If so, use that. f) if we didn't just exit with an empty buffer.

That empty buffer *should* trigger revision error codes since it won't point to any valid path and it also triggers the regular error code in add_submodule_odb so it handles that with showing not initizlied.

This method is less work then re-implementing a _gently() variant for all of these functions.

Stefan, does this make sense and seem reasonable?

If we just die when submodule_from_path fails I think it's bad for the submodule=* formats beside short. I don't know if it causes problems for revision code or not... I think falling back to resetting the buffer as our way of indicating error is reasonable enough...

Thanks, Jake

Previous: Junio C HamanoNext: Stefan Beller
Message 23 of 26 in “submodule inline diff format”
  1. 0/9 submodule inline diff formatJacob Keller, Aug 22, 2016
  2. 1/9 Git 2.10-rc1Jacob Keller, Aug 22, 2016
  3. Stefan BellerAug 23, 2016
  4. Jacob KellerAug 23, 2016
  5. 7/9 submodule: convert show_submodule_summary to use struct object_id *Jacob Keller, Aug 22, 2016
  6. 3/9 diff.c: remove output_prefix_length fieldJacob Keller, Aug 22, 2016
  7. 6/9 allow do_submodule_path to work even if submodule isn't checked outJacob Keller, Aug 22, 2016
  8. 4/9 graph: add support for --line-prefix on all graph-aware outputJacob Keller, Aug 22, 2016
  9. 5/9 diff: prepare for additional submodule formatsJacob Keller, Aug 22, 2016
  10. 2/9 cache: add empty_tree_oid object and helper functionJacob Keller, Aug 22, 2016
  11. 9/9 diff: teach diff to display submodule difference with an inline diffJacob Keller, Aug 22, 2016
  12. 8/9 submodule: refactor show_submodule_summary with helper functionJacob Keller, Aug 22, 2016
  13. Junio C HamanoAug 23, 2016
  14. Jacob KellerAug 24, 2016
  15. Stefan BellerAug 23, 2016
  16. Jacob KellerAug 23, 2016
  17. Junio C HamanoAug 23, 2016
  18. Stefan BellerAug 23, 2016
  19. Jacob KellerAug 25, 2016
  20. Stefan BellerAug 25, 2016
  21. Jacob KellerAug 25, 2016
  22. Junio C HamanoAug 25, 2016
  23. Jacob KellerAug 25, 2016
  24. Stefan BellerAug 26, 2016
  25. Keller, Jacob EAug 26, 2016
  26. Jacob KellerAug 25, 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.