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

Re: [GSoC][PATCH] submodule: port submodule subcommand 'add' from shell to C

From
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Date
Aug 26, 2020, 10:54 UTC
Message-ID
<5899bf6e-f61f-8a19-196d-d38d611dc037@gmail.com>
In-Reply-To
<CAP6+3T2FbjKc35QYiDmaezzKbkrxEOcBqzirm032_tTU2foZ=Q@mail.gmail.com>
On 26-08-2020 14:57, Shourya Shukla wrote:
Show 40 quoted lines
> On 8/25/20, Kaartic Sivaraam <kaartic.sivaraam@gmail.com> wrote:
>>
>> This part results in a difference in error message in shell and C
>> versions.
>>
>> -- 8< --
>> $ # Shell version
>> $ git submodule add ../subm1 sub
>> A git directory for 'sub' is found locally with remote(s):
>>   origin        /me/subm1
>> If you want to reuse this local git directory instead of cloning again from
>>   /me/subm1
>> use the '--force' option. If the local git directory is not the correct
>> repo
>> or you are unsure what this means choose another name with the '--name'
>> option.
>> $
>> $ # C version
>> $ git submodule add ../subm1 sub
>> A git directory for 'sub' is found locally with remote(s):
>>   origin        /me/subm1
>> error: If you want to reuse this local git directory instead of cloning
>> again from
>>    /me/subm1
>> use the '--force' option. If the local git directory is not the correct
>> repo
>> or you are unsure what this means choose another name with the '--name'
>> option.
>> -- >8 --
>>
>> Note how the third line is oddly prefixed by a `error` unlike the rest
>> of the lines. It would be nice if we could weed out that inconsistency.
>> We could probably use `advise()` for printing the last four lines and
>> `error()` for the lines above them.
> 
> Understood. I will correct this part. BTW, you surely are talking
> about error() on
> the first 2 lines? I think fprintf(stderr, _()) is OK for them otherwise they
> will be prefixed by 'error:' which will not be in line with the shell version.
> 

Yes. It's better to prefix them with `error` because well... it is an error. I realize the shell version didn't explicitly do this but that doesn't necessarily mean the error message was helpful without the prefix. AFAIK, many Git commands prefix their error messages with `fatal` or `error` which makes it easy to distinguish error messages from actual program output in the terminal. So, it's good to do the same here.

-- 
Sivaraam
Previous: Shourya ShuklaNext: Shourya Shukla
Message 6 of 12 in “submodule: port submodule subcommand 'add' from shell to C”
  1. Shourya ShuklaAug 24, 2020
  2. Junio C HamanoAug 24, 2020
  3. Kaartic SivaraamAug 24, 2020
  4. Junio C HamanoAug 24, 2020
  5. Shourya ShuklaAug 26, 2020
  6. Kaartic SivaraamAug 26, 2020
  7. Shourya ShuklaAug 26, 2020
  8. Kaartic SivaraamAug 30, 2020
  9. Shourya ShuklaAug 31, 2020
  10. Kaartic SivaraamSep 1, 2020
  11. Shourya ShuklaSep 2, 2020
  12. Kaartic SivaraamSep 3, 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.