From: Thomas Rast <trast@student.ethz.ch>
To: <git@vger.kernel.org>
Cc: Bo Yang <struggleyb.nku@gmail.com>
Subject: [PATCH v7 2/5] blame: introduce $ as "end of file" in -L syntax
Date: Thu, 7 Jun 2012 12:23:26 +0200 [thread overview]
Message-ID: <d9e1235303c949849b9acfa37fc9e9a780d93873.1339063659.git.trast@student.ethz.ch> (raw)
In-Reply-To: <cover.1339063659.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.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.c b/line.c
index afd2e3b..a7f33ed 100644
--- a/line.c
+++ b/line.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.7.11.rc1.243.gbf4713c
next prev parent reply other threads:[~2012-06-07 10:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-07 10:23 [PATCH v7 0/5] git log -L, all new and shiny Thomas Rast
2012-06-07 10:23 ` [PATCH v7 1/5] Refactor parse_loc Thomas Rast
2012-06-07 10:23 ` Thomas Rast [this message]
2012-06-07 17:23 ` [PATCH v7 2/5] blame: introduce $ as "end of file" in -L syntax Junio C Hamano
2012-06-07 17:44 ` Thomas Rast
2012-06-07 10:23 ` [PATCH v7 3/5] Export three functions from diff.c Thomas Rast
2012-06-07 17:44 ` Junio C Hamano
2012-06-07 10:23 ` [PATCH v7 4/5] Export rewrite_parents() for 'log -L' Thomas Rast
2012-06-07 10:23 ` [PATCH v7 5/5] Implement line-history search (git log -L) Thomas Rast
2012-06-07 17:42 ` Junio C Hamano
2012-06-07 17:52 ` Thomas Rast
2012-06-10 9:38 ` Zbigniew Jędrzejewski-Szmek
2012-06-15 4:40 ` [PATCH v7 0/5] git log -L, all new and shiny Junio C Hamano
2012-06-15 13:29 ` Thomas Rast
2012-06-15 15:23 ` Junio C Hamano
2012-06-16 6:01 ` Junio C Hamano
2012-06-19 10:11 ` Thomas Rast
2012-06-19 10:33 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d9e1235303c949849b9acfa37fc9e9a780d93873.1339063659.git.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=struggleyb.nku@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).