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

Re: [PATCH v8 2/5] blame: introduce $ as "end of file" in -L syntax

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 28, 2013, 17:18 UTC
Message-ID
<7vk3psicgf.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7973d90cfcd86a3c15776b8718ad6bd84ee7b4ac.1362069310.git.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
> To save the user a lookup of the last line number, introduce $ as a
> shorthand for the last line.  This is mostly useful to spell "until
> the end of the file" as '-L<begin>,$'.

Doesn't "-L <begin>" or "-L <begin>," do that already? If it were to introduce "-L $-4," or "-L$-4,+2", I would understand why the addition may be useful, but otherwise I do not think it adds much value.

Show 40 quoted lines
>
> Signed-off-by: Thomas Rast <trast@student.ethz.ch>
> ---
>  Documentation/line-range-format.txt | 6 ++++++
>  line-log.c                          | 8 ++++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/Documentation/line-range-format.txt b/Documentation/line-range-format.txt
> index 265bc23..9ce0688 100644
> --- a/Documentation/line-range-format.txt
> +++ b/Documentation/line-range-format.txt
> @@ -16,3 +16,9 @@ starting at the line given by <start>.
>  This is only valid for <end> and will specify a number
>  of lines before or after the line given by <start>.
>  +
> +
> +- `$`
> ++
> +A literal dollar sign can be used as a shorthand for the last line in
> +the file.
> ++
> diff --git a/line-log.c b/line-log.c
> index a24a86b..b167b00 100644
> --- a/line-log.c
> +++ b/line-log.c
> @@ -15,6 +15,14 @@ const char *parse_loc(const char *spec, nth_line_fn_t nth_line,
>  	regmatch_t match[1];
>  
>  	/*
> +	 * $ is a synonym for "the end of the file".
> +	 */
> +	if (spec[0] == '$') {
> +		*ret = lines;
> +		return spec + 1;
> +	}
> +
> +	/*
>  	 * Allow "-L <something>,+20" to mean starting at <something>
>  	 * for 20 lines, or "-L <something>,-5" for 5 lines ending at
>  	 * <something>.
Previous: Thomas RastNext: Junio C Hamano
Message 6 of 21 in “git log -L”
  1. 0/5 git log -LThomas Rast, Feb 28, 2013
  2. 1/5 Refactor parse_locThomas Rast, Feb 28, 2013
  3. Junio C HamanoFeb 28, 2013
  4. Thomas RastFeb 28, 2013
  5. 2/5 blame: introduce $ as "end of file" in -L syntaxThomas Rast, Feb 28, 2013
  6. Junio C HamanoFeb 28, 2013
  7. Junio C HamanoMar 12, 2013
  8. Thomas RastMar 13, 2013
  9. Junio C HamanoMar 13, 2013
  10. 3/5 Export rewrite_parents() for 'log -L'Thomas Rast, Feb 28, 2013
  11. Junio C HamanoFeb 28, 2013
  12. 4/5 Implement line-history search (git log -L)Thomas Rast, Feb 28, 2013
  13. Junio C HamanoFeb 28, 2013
  14. Thomas RastFeb 28, 2013
  15. Junio C HamanoFeb 28, 2013
  16. Thomas RastFeb 28, 2013
  17. Junio C HamanoFeb 28, 2013
  18. Thomas RastMar 1, 2013
  19. Thomas RastMar 1, 2013
  20. 5/5 log -L: :pattern:file syntax to find by funcnameThomas Rast, Feb 28, 2013
  21. Junio C HamanoFeb 28, 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.