From: Thomas Rast <trast@student.ethz.ch>
To: <git@vger.kernel.org>
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Bo Yang" <struggleyb.nku@gmail.com>,
"Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl>,
"Will Palmer" <wmpalmer@gmail.com>
Subject: [PATCH v8 2/5] blame: introduce $ as "end of file" in -L syntax
Date: Thu, 28 Feb 2013 17:38:20 +0100 [thread overview]
Message-ID: <7973d90cfcd86a3c15776b8718ad6bd84ee7b4ac.1362069310.git.trast@student.ethz.ch> (raw)
In-Reply-To: <cover.1362069310.git.trast@student.ethz.ch>
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>,$'.
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>.
--
1.8.2.rc1.388.g1bd82c8
next prev parent reply other threads:[~2013-02-28 16:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-28 16:38 [PATCH v8 0/5] git log -L Thomas Rast
2013-02-28 16:38 ` [PATCH v8 1/5] Refactor parse_loc Thomas Rast
2013-02-28 17:16 ` Junio C Hamano
2013-02-28 19:24 ` Thomas Rast
2013-02-28 16:38 ` Thomas Rast [this message]
2013-02-28 17:18 ` [PATCH v8 2/5] blame: introduce $ as "end of file" in -L syntax Junio C Hamano
2013-03-12 22:34 ` Junio C Hamano
2013-03-13 7:52 ` Thomas Rast
2013-03-13 16:05 ` Junio C Hamano
2013-02-28 16:38 ` [PATCH v8 3/5] Export rewrite_parents() for 'log -L' Thomas Rast
2013-02-28 17:19 ` Junio C Hamano
2013-02-28 16:38 ` [PATCH v8 4/5] Implement line-history search (git log -L) Thomas Rast
2013-02-28 17:51 ` Junio C Hamano
2013-02-28 19:32 ` Thomas Rast
2013-02-28 20:37 ` Junio C Hamano
2013-02-28 21:41 ` Thomas Rast
2013-02-28 22:23 ` Junio C Hamano
2013-03-01 8:49 ` Thomas Rast
2013-03-01 14:59 ` Thomas Rast
2013-02-28 16:38 ` [PATCH v8 5/5] log -L: :pattern:file syntax to find by funcname Thomas Rast
2013-02-28 19:56 ` [PATCH v8 0/5] git log -L Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7973d90cfcd86a3c15776b8718ad6bd84ee7b4ac.1362069310.git.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=struggleyb.nku@gmail.com \
--cc=wmpalmer@gmail.com \
--cc=zbyszek@in.waw.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).