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

Re: [RFC/PATCH] ls-remote: optionally return non-zero on non-existing refs

From
Junio C Hamano <gitster@pobox.com>
Date
May 18, 2011, 18:28 UTC
Message-ID
<7v7h9ndfs9.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4DD3D490.1090503@elegosoft.com>
Michael Schubert <mschub@elegosoft.com> writes:
Show 9 quoted lines
> git ls-remote returns zero no matter if the given references were found
> or not. Teach ls-remote an option --exit-status to make it optionally
> returning a non-zero status.
>
> Signed-off-by: Michael Schubert <mschub@elegosoft.com>
> ---
>
> If there is just one existing ref in a list of non-exising refs, this will
> return zero though - as "git show-ref" does.
That's Ok, but...
Show 14 quoted lines
> @@ -35,6 +35,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
> ...
> +	int exit_code = 0;
> ...
> @@ -74,6 +75,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
> ...
> +			if (!strcmp("--exit-code", arg) || !strcmp("-e", arg)) {
> +				exit_code = 1;
> +				continue;
> ...
> @@ -115,12 +120,15 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
> ...
> +	return (exit_code) ? 2 : 0;
>  }
What is this insanity?
Wouldn't it be a lot more straightforward to write it like this?
	int status = 0;
	...
		if (!strcmp("--exit-code", arg)) {
			/* when we do not find any, return this value */
 			status = 2;
                        continue;
		}
	...
	return status;
Previous: Thiago FarinaNext: Michael Schubert
Message 6 of 10 in “Exit code of git-ls-remote”
  1. Kacper KornetMay 12, 2011
  2. Junio C HamanoMay 12, 2011
  3. Junio C HamanoMay 12, 2011
  4. ls-remote: optionally return non-zero on non-existing refsMichael Schubert, May 18, 2011
  5. Thiago FarinaMay 18, 2011
  6. Junio C HamanoMay 18, 2011
  7. ls-remote: optionally return non-zero on non-existing refsMichael Schubert, May 18, 2011
  8. Andreas SchwabMay 18, 2011
  9. Junio C HamanoMay 18, 2011
  10. Michael SchubertMay 18, 2011

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.