Re: [PATCH 2/2] check-attr: Add --stdin-paths option

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

 



Dmitry Potapov schrieb:
> +static void check_attr_stdin_paths(int cnt, struct git_attr_check *check,
> +	const char** name)
> +{
> +	struct strbuf buf, nbuf;
> +
> +	strbuf_init(&buf, 0);
> +	strbuf_init(&nbuf, 0);
> +	while (strbuf_getline(&buf, stdin, '\n') != EOF) {
> +		if (buf.buf[0] == '"') {
> +			strbuf_reset(&nbuf);
> +			if (unquote_c_style(&nbuf, buf.buf, NULL))
> +				die("line is badly quoted");
> +			strbuf_swap(&buf, &nbuf);
> +		}
> +		check_attr(cnt, check, name, buf.buf);
> +	}
> +	strbuf_release(&buf);
> +	strbuf_release(&nbuf);
> +}
> +

We know that you will want to use this feature in gitk to reduce the
number of fork()s. But you've a problem: gitk will first write a path to
git-check-addr's stdin, and then wait for the result on its stdout. But
this is a classic pitfall: You are not guaranteed that something will be
returned from stdout right away due to buffering. The least that is needed
is fflush(stdout) in this loop (after each iteration!) so that gitk sees
some result and does not hang forever.

-- Hannes
--
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]

  Powered by Linux