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

Re: [PATCH v2] Let submodule command exit with error status if path does not exist

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 13, 2012, 17:11 UTC
Message-ID
<7vvcgmemyk.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120813163911.GA6418@book.hvoigt.net>
Heiko Voigt <hvoigt@hvoigt.net> writes:
> How about I update CodingGuidelines according to the rules you
> suggested? Then other people know how we prefer bash functions and if
> statements to look like.

OK. I was hoping that "imitate surrounding code" was sufficient, but it seems many parts of the codebase have deteriorated enough to make that rule no longer easy to follow.

Show 7 quoted lines
>> Style:
>> 
>> 	if test -z "$sm_path"
>> 	then
>> 		exit 1
>
> See above. If you agree I would add this style to the guidelines.
Likewise.
Show 21 quoted lines
>> I know module_list would have said "error: pathspec 'no-such' did
>> not match any file(s) known to git.  Did you forget to git add"
>> already, but because that comes at the very end of the input to the
>> filter written in perl (and with the way the filter is coded, it
>> will stay at the end), I am not sure if the user would notice it if
>> we exit like this.  By the time we hit this exit, we would have seen
>> "Entering $sm_path..." followed by whatever message given while in
>> the submodule for all the submodules that comes out of module_list,
>> no?
>> 
>> How about doing it this way to avoid that issue, to make sure we die
>> immediately after the typo is diagnosed without touching anything?
>
> I like it, your approach combines the atomicity of my first patch with
> the efficiency of not calling ls-files twice. I was hesitant to change
> to much code just to get the exit code right, but your approach looks
> good to me.
>
> Should I send an updated patch? Or do you just want to squash this in.
> Since now only the tests are from me what should we do with the
> ownership?

That is your itch and the idea and the bulk of the changes remains to be yours in any case, methinks.

By the way, there is no reason for my patch to be unshifting the "#unmatch" token into the array and spewing the array out, if the readers are always going to stop upon seeing "#unmatch" without touching any submodule that is named correctly on the command line. In other words, the following should suffice:

	while (<>) {
		... accumulate in @out ...
	}
	if ($unmatched) {
		print "#unmatched\n";
	} else {
		print for (@out);
	}
Previous: Heiko VoigtNext: Heiko Voigt
Message 7 of 9 in “git submodule return status”
  1. Daniel MildeJun 28, 2012
  2. Let submodule command exit with error status if path does not existHeiko Voigt, Aug 9, 2012
  3. Junio C HamanoAug 9, 2012
  4. Let submodule command exit with error status if path does not existHeiko Voigt, Aug 11, 2012
  5. Junio C HamanoAug 12, 2012
  6. Heiko VoigtAug 13, 2012
  7. Junio C HamanoAug 13, 2012
  8. Let submodule command exit with error status if path does not existHeiko Voigt, Aug 14, 2012
  9. Junio C HamanoAug 14, 2012

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.