From: Junio C Hamano Date: Thu, 28 Feb 2013 17:18:40 GMT Subject: Re: [PATCH v8 2/5] blame: introduce $ as "end of file" in -L syntax Message-ID: <7vk3psicgf.fsf@alter.siamese.dyndns.org> In-Reply-To: <7973d90cfcd86a3c15776b8718ad6bd84ee7b4ac.1362069310.git.trast@student.ethz.ch> Thomas Rast 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,$'. Doesn't "-L " or "-L ," 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. > > Signed-off-by: Thomas Rast > --- > 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 . > This is only valid for and will specify a number > of lines before or after the line given by . > + > + > +- `$` > ++ > +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 ,+20" to mean starting at > * for 20 lines, or "-L ,-5" for 5 lines ending at > * .