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

Re: [PATCH v3] cherry-pick: make sure all input objects are commits

From
Junio C Hamano <junio@pobox.com>
Date
Apr 15, 2013, 18:29 UTC
Message-ID
<7vehebsl4h.fsf@alter.siamese.dyndns.org>
In-Reply-To
<87vc7odvzi.fsf@linux-k42r.v.cablecom.net>
Thomas Rast <trast@inf.ethz.ch> writes:
Show 28 quoted lines
> From a cursory glance it looks like it's actually an existing bug in
> read_revisions_from_stdin or handle_revision_arg, depending on which way
> you look at it.  read_revisions_from_stdin passes its temporary buffer
> down to handle_revision_arg:
>
>         struct strbuf sb;
>         [...]
>         strbuf_init(&sb, 1000);
>         while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) {
>                 [...]
>                 if (handle_revision_arg(sb.buf, revs, 0, REVARG_CANNOT_BE_FILENAME))
>                         die("bad revision '%s'", sb.buf);
>         }
>
> But handle_revision_arg ends up just stuffing that parameter into the
> revision-walker options via some helpers:
>
> 	add_rev_cmdline(revs, object, arg_, REV_CMD_REV, flags ^ local_flags);
> 	add_pending_object_with_mode(revs, object, arg, oc.mode);
>
> This seems to have been lurking since 281eee4 (revision: keep track of
> the end-user input from the command line, 2011-08-25).
>
> Junio, at which level should we fix it?  We could of course have
> read_revisions_from_stdin make a copy of the buffers it passes
> down, but perhaps it would be less surprising to instead have
> handle_revision_arg make sure it makes a copy of everything it
> "keeps"?
That sounds like the right way to go to me.
Show 16 quoted lines
> The easy fix of course is just this:
>
> diff --git i/revision.c w/revision.c
> index 3a20c96..181a8db 100644
> --- i/revision.c
> +++ w/revision.c
> @@ -1277,7 +1277,8 @@ static void read_revisions_from_stdin(struct rev_info *revs,
>  			}
>  			die("options not supported in --stdin mode");
>  		}
> -		if (handle_revision_arg(sb.buf, revs, 0, REVARG_CANNOT_BE_FILENAME))
> +		if (handle_revision_arg(xstrdup(sb.buf), revs, 0,
> +					REVARG_CANNOT_BE_FILENAME))
>  			die("bad revision '%s'", sb.buf);
>  	}
>  	if (seen_dashdash)
Previous: Thomas RastNext: Junio C Hamano
Message 12 of 17 in “cherry-pick: better error message when the parameter is a non-commit”
  1. cherry-pick: better error message when the parameter is a non-commitMiklos Vajna, Apr 3, 2013
  2. Miklos VajnaApr 8, 2013
  3. Junio C HamanoApr 8, 2013
  4. Junio C HamanoApr 8, 2013
  5. cherry-pick: make sure all input objects are commitsMiklos Vajna, Apr 11, 2013
  6. Ramkumar RamachandraApr 11, 2013
  7. Miklos VajnaApr 11, 2013
  8. Ramkumar RamachandraApr 11, 2013
  9. cherry-pick: make sure all input objects are commitsMiklos Vajna, Apr 11, 2013
  10. Ramkumar RamachandraApr 11, 2013
  11. Thomas RastApr 15, 2013
  12. Junio C HamanoApr 15, 2013
  13. Junio C HamanoApr 15, 2013
  14. Michael HaggertyApr 16, 2013
  15. Junio C HamanoMay 9, 2013
  16. Junio C HamanoMay 9, 2013
  17. Miklos VajnaMay 10, 2013

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.