Re: [PATCH 3/3] notes remove: --stdin reads from the standard input

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

 



On Thu, May 19, 2011 at 10:55:38AM -0700, Junio C Hamano wrote:

> >> +	if (from_stdin) {
> >> +		struct strbuf sb = STRBUF_INIT;
> >> +		while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) {
> >> +			int len = sb.len;
> >> +			if (len && sb.buf[len - 1] == '\n')
> >> +				sb.buf[--len] = '\0';
> >> +			retval |= remove_one_note(t, sb.buf, flag);
> >> +		}
> >> +	}
> >
> > Wouldn't strbuf_rtrim (or even strbuf_trim) be useful here?
> 
> Thanks for noticing.
> 
> I just mimicked what was done to the result of strbuf_getwholeline() in
> other places (I think from revision.c but I am not sure).

I am tempted to say that other callsites should be "upgraded" to
strbuf_trim. Is there any reason we should not be liberal in accepting
something like:

  echo "  refs/heads/foo  " | git rev-list --stdin

?

I guess for pathspecs we would want to be more literal, though, so maybe
it is a stupid idea.

> An incremental correction, relative to what I had in 'pu' overnight, looks
> like this.

Thanks. BTW, I was too busy picking this one nit to mention that the
general direction of the series is a nice improvement. :)

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