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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael Schubert <mschub@xxxxxxxxxxxxx> writes:

> 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@xxxxxxxxxxxxx>
> ---
>
> 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...

> @@ -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;

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]