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

Re: [PATCH] read_revisions_from_stdin: make copies for handle_revision_arg

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 16, 2013, 18:17 UTC
Message-ID
<7vzjwyl4q4.fsf@alter.siamese.dyndns.org>
In-Reply-To
<c68f7df5367d254360ddf184fa1eaf6b8c3bef18.1366106134.git.trast@inf.ethz.ch>
Thomas Rast <trast@inf.ethz.ch> writes:
Show 20 quoted lines
> read_revisions_from_stdin() has passed pointers to its read buffer
> down to handle_revision_arg() since its inception way back in 42cabc3
> (Teach rev-list an option to read revs from the standard input.,
> 2006-09-05).  Even back then, this was a bug: through
> add_pending_object, the argument was recorded in the object_array's
> 'name' field.
>
> Fix it by making a copy whenever read_revisions_from_stdin() passes an
> argument down the callchain.  The other caller runs handle_revision_arg()
> on argv[], where it would be redundant to make a copy.
>
> Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
> ---
>
>> So I changed my mind.  Your "easy fix" looks to me the right thing
>> to do.
>
> So here's the same with a commit message and signoff.  I hope I got my
> history right; I didn't look too long if it had any users, but it was
> definitely recorded.
Thanks.
Show 19 quoted lines
>
>
>  revision.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/revision.c b/revision.c
> index 3a20c96..181a8db 100644
> --- a/revision.c
> +++ b/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: Karsten Blees
Message 13 of 36 in “Improve git-status --ignored”
  1. 0/8 Improve git-status --ignoredKarsten Blees, Mar 18, 2013
  2. Junio C HamanoMar 19, 2013
  3. Duy NguyenMar 19, 2013
  4. Karsten BleesMar 19, 2013
  5. Junio C HamanoMar 19, 2013
  6. Duy NguyenMar 19, 2013
  7. 00/14 Improve git-status --ignoredKarsten Blees, Apr 15, 2013
  8. 01/14 dir.c: git-status --ignored: don't drop ignored directoriesKarsten Blees, Apr 15, 2013
  9. Ramkumar RamachandraApr 16, 2013
  10. Karsten BleesApr 17, 2013
  11. 02/14 dir.c: git-status --ignored: don't list files in ignored directoriesKarsten Blees, Apr 15, 2013
  12. read_revisions_from_stdin: make copies for handle_revision_argThomas Rast, Apr 16, 2013
  13. Junio C HamanoApr 16, 2013
  14. 03/14 dir.c: git-status --ignored: don't list empty ignored directoriesKarsten Blees, Apr 15, 2013
  15. Ramkumar RamachandraApr 16, 2013
  16. Karsten BleesApr 17, 2013
  17. 04/14 dir.c: git-ls-files --directories: don't hide empty directoriesKarsten Blees, Apr 15, 2013
  18. 05/14 dir.c: git-status --ignored: don't list empty directories as ignoredKarsten Blees, Apr 15, 2013
  19. 06/14 dir.c: make 'git-status --ignored' work within leading directoriesKarsten Blees, Apr 15, 2013
  20. 07/14 dir.c: git-clean -d -X: don't delete tracked directoriesKarsten Blees, Apr 15, 2013
  21. 08/14 dir.c: factor out parts of last_exclude_matching for later reuseKarsten Blees, Apr 15, 2013
  22. 09/14 dir.c: move prep_excludeKarsten Blees, Apr 15, 2013
  23. 10/14 dir.c: unify is_excluded and is_path_excluded APIsKarsten Blees, Apr 15, 2013
  24. Junio C HamanoApr 15, 2013
  25. 11/14 dir.c: replace is_path_excluded with now equivalent is_excluded APIKarsten Blees, Apr 15, 2013
  26. 12/14 dir.c: git-status: avoid is_excluded checks for tracked filesKarsten Blees, Apr 15, 2013
  27. 13/14 dir.c: git-status --ignored: don't scan the work tree three timesKarsten Blees, Apr 15, 2013
  28. 14/14 dir.c: git-status --ignored: don't scan the work tree twiceKarsten Blees, Apr 15, 2013
  29. Junio C HamanoApr 15, 2013
  30. Junio C HamanoApr 15, 2013
  31. Karsten BleesApr 15, 2013
  32. Junio C HamanoApr 15, 2013
  33. Karsten BleesApr 17, 2013
  34. Junio C HamanoApr 17, 2013
  35. 11/14 dir.c: replace is_path_excluded with now equivalent is_excluded APIKarsten Blees, Apr 17, 2013
  36. 14/14 dir.c: git-status --ignored: don't scan the work tree twiceKarsten Blees, Apr 17, 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.