* [PATCH 0/3] minor git-jump improvements @ 2016-07-22 16:27 Jeff King 2016-07-22 16:28 ` [PATCH 1/3] contrib/git-jump: fix greedy regex when matching hunks Jeff King ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: Jeff King @ 2016-07-22 16:27 UTC (permalink / raw) To: git Here are a few quick fixes and features for git-jump. The first is a bug I noticed and fixed recently. And that reminded me of the second one, which I'd been carrying in my local copy for a long time. [1/3]: contrib/git-jump: fix greedy regex when matching hunks [2/3]: contrib/git-jump: add whitespace-checking mode [3/3]: contrib/git-jump: fix typo in README -Peff ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] contrib/git-jump: fix greedy regex when matching hunks 2016-07-22 16:27 [PATCH 0/3] minor git-jump improvements Jeff King @ 2016-07-22 16:28 ` Jeff King 2016-07-22 16:29 ` [PATCH 2/3] contrib/git-jump: add whitespace-checking mode Jeff King ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: Jeff King @ 2016-07-22 16:28 UTC (permalink / raw) To: git The hunk-header regex looks for "\+\d+" to find the post-image line numbers, but it skips the pre-image line numbers with a simple ".*". That means we may greedily eat the post-image numbers and match a "\+\d" further on, in the funcname text. For example, commit 6b9c38e has this hunk header: diff --git a/t/t0006-date.sh b/t/t0006-date.sh [...] @@ -50,8 +50,8 @@ check_show iso-local "$TIME" '2016-06-15 14:13:20 +0000' If you run: git checkout 6b9c38e git jump diff HEAD^ t/ it will erroneously match "+0000" as the starting line number and jump there, rather than line 50. We can fix it by just making the "skip" regex non-greedy, taking the first "+" we see, which should be the post-image line information. Signed-off-by: Jeff King <peff@peff.net> --- contrib/git-jump/git-jump | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump index dc90cd6..1f1b996 100755 --- a/contrib/git-jump/git-jump +++ b/contrib/git-jump/git-jump @@ -25,7 +25,7 @@ mode_diff() { perl -ne ' if (m{^\+\+\+ (.*)}) { $file = $1; next } defined($file) or next; - if (m/^@@ .*\+(\d+)/) { $line = $1; next } + if (m/^@@ .*?\+(\d+)/) { $line = $1; next } defined($line) or next; if (/^ /) { $line++; next } if (/^[-+]\s*(.*)/) { -- 2.9.2.506.g8452fe7 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] contrib/git-jump: add whitespace-checking mode 2016-07-22 16:27 [PATCH 0/3] minor git-jump improvements Jeff King 2016-07-22 16:28 ` [PATCH 1/3] contrib/git-jump: fix greedy regex when matching hunks Jeff King @ 2016-07-22 16:29 ` Jeff King 2016-07-22 16:35 ` [PATCH v2 " Jeff King 2016-07-22 16:30 ` [PATCH 3/3] contrib/git-jump: fix typo in README Jeff King 2016-07-23 8:52 ` [PATCH 0/3] minor git-jump improvements Johannes Schindelin 3 siblings, 1 reply; 7+ messages in thread From: Jeff King @ 2016-07-22 16:29 UTC (permalink / raw) To: git If you have whitespace errors in lines you've introduced, it can be convenient to be able to jump directly to them for fixing. You can't quite use "git jump diff" for this, because though it passes arbitrary options to "git diff", it expects to see an actual unified diff in the output. Whereas "git diff --check" actually produces lines that look like compiler quickfix lines already, meaning we just need to run it and feed the output directly to the editor. Signed-off-by: Jeff King <peff@peff.net> --- contrib/git-jump/git-jump | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump index 1f1b996..427f206 100755 --- a/contrib/git-jump/git-jump +++ b/contrib/git-jump/git-jump @@ -12,6 +12,8 @@ diff: elements are diff hunks. Arguments are given to diff. merge: elements are merge conflicts. Arguments are ignored. grep: elements are grep hits. Arguments are given to grep. + +ws: elements are whitespace errors. Arguments are given to diff --check. EOF } @@ -55,6 +57,10 @@ mode_grep() { ' } +mode_ws() { + git diff --check "$@" +} + if test $# -lt 1; then usage >&2 exit 1 -- 2.9.2.506.g8452fe7 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] contrib/git-jump: add whitespace-checking mode 2016-07-22 16:29 ` [PATCH 2/3] contrib/git-jump: add whitespace-checking mode Jeff King @ 2016-07-22 16:35 ` Jeff King 0 siblings, 0 replies; 7+ messages in thread From: Jeff King @ 2016-07-22 16:35 UTC (permalink / raw) To: git On Fri, Jul 22, 2016 at 12:29:45PM -0400, Jeff King wrote: > If you have whitespace errors in lines you've introduced, it > can be convenient to be able to jump directly to them for > fixing. You can't quite use "git jump diff" for this, > because though it passes arbitrary options to "git diff", it > expects to see an actual unified diff in the output. > > Whereas "git diff --check" actually produces lines that look > like compiler quickfix lines already, meaning we just need > to run it and feed the output directly to the editor. > > Signed-off-by: Jeff King <peff@peff.net> > --- > contrib/git-jump/git-jump | 6 ++++++ > 1 file changed, 6 insertions(+) Whoops. I updated the README, too, but forgot to actually commit it. Here's an updated patch. -- >8 -- Subject: contrib/git-jump: add whitespace-checking mode If you have whitespace errors in lines you've introduced, it can be convenient to be able to jump directly to them for fixing. You can't quite use "git jump diff" for this, because though it passes arbitrary options to "git diff", it expects to see an actual unified diff in the output. Whereas "git diff --check" actually produces lines that look like compiler quickfix lines already, meaning we just need to run it and feed the output directly to the editor. Signed-off-by: Jeff King <peff@peff.net> --- contrib/git-jump/README | 4 +++- contrib/git-jump/git-jump | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/contrib/git-jump/README b/contrib/git-jump/README index 1cebc32..3e0b65b 100644 --- a/contrib/git-jump/README +++ b/contrib/git-jump/README @@ -29,7 +29,7 @@ Obviously this trivial case isn't that interesting; you could just open `foo.c` yourself. But when you have many changes scattered across a project, you can use the editor's support to "jump" from point to point. -Git-jump can generate three types of interesting lists: +Git-jump can generate four types of interesting lists: 1. The beginning of any diff hunks. @@ -37,6 +37,8 @@ Git-jump can generate three types of interesting lists: 3. Any grep matches. + 4. Any whitespace errors detected by `git diff --check`. + Using git-jump -------------- diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump index 1f1b996..427f206 100755 --- a/contrib/git-jump/git-jump +++ b/contrib/git-jump/git-jump @@ -12,6 +12,8 @@ diff: elements are diff hunks. Arguments are given to diff. merge: elements are merge conflicts. Arguments are ignored. grep: elements are grep hits. Arguments are given to grep. + +ws: elements are whitespace errors. Arguments are given to diff --check. EOF } @@ -55,6 +57,10 @@ mode_grep() { ' } +mode_ws() { + git diff --check "$@" +} + if test $# -lt 1; then usage >&2 exit 1 -- 2.9.2.506.g8452fe7 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] contrib/git-jump: fix typo in README 2016-07-22 16:27 [PATCH 0/3] minor git-jump improvements Jeff King 2016-07-22 16:28 ` [PATCH 1/3] contrib/git-jump: fix greedy regex when matching hunks Jeff King 2016-07-22 16:29 ` [PATCH 2/3] contrib/git-jump: add whitespace-checking mode Jeff King @ 2016-07-22 16:30 ` Jeff King 2016-07-23 8:52 ` [PATCH 0/3] minor git-jump improvements Johannes Schindelin 3 siblings, 0 replies; 7+ messages in thread From: Jeff King @ 2016-07-22 16:30 UTC (permalink / raw) To: git Signed-off-by: Jeff King <peff@peff.net> --- contrib/git-jump/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/git-jump/README b/contrib/git-jump/README index 1cebc32..202b499 100644 --- a/contrib/git-jump/README +++ b/contrib/git-jump/README @@ -83,7 +83,7 @@ complete list of files and line numbers for each match. Limitations ----------- -This scripts was written and tested with vim. Given that the quickfix +This script was written and tested with vim. Given that the quickfix format is the same as what gcc produces, I expect emacs users have a similar feature for iterating through the list, but I know nothing about how to activate it. -- 2.9.2.506.g8452fe7 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] minor git-jump improvements 2016-07-22 16:27 [PATCH 0/3] minor git-jump improvements Jeff King ` (2 preceding siblings ...) 2016-07-22 16:30 ` [PATCH 3/3] contrib/git-jump: fix typo in README Jeff King @ 2016-07-23 8:52 ` Johannes Schindelin 2016-07-24 15:32 ` Jeff King 3 siblings, 1 reply; 7+ messages in thread From: Johannes Schindelin @ 2016-07-23 8:52 UTC (permalink / raw) To: Jeff King; +Cc: git Hi Peff, On Fri, 22 Jul 2016, Jeff King wrote: > Here are a few quick fixes and features for git-jump. The first is a bug > I noticed and fixed recently. And that reminded me of the second one, > which I'd been carrying in my local copy for a long time. > > [1/3]: contrib/git-jump: fix greedy regex when matching hunks > [2/3]: contrib/git-jump: add whitespace-checking mode > [3/3]: contrib/git-jump: fix typo in README These 3 patches look good to me. They also made me aware of git-jump's existence and purpose. I think I shall use this script a lot myself from now on. Thanks, Dscho ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] minor git-jump improvements 2016-07-23 8:52 ` [PATCH 0/3] minor git-jump improvements Johannes Schindelin @ 2016-07-24 15:32 ` Jeff King 0 siblings, 0 replies; 7+ messages in thread From: Jeff King @ 2016-07-24 15:32 UTC (permalink / raw) To: Johannes Schindelin; +Cc: git On Sat, Jul 23, 2016 at 10:52:09AM +0200, Johannes Schindelin wrote: > On Fri, 22 Jul 2016, Jeff King wrote: > > > Here are a few quick fixes and features for git-jump. The first is a bug > > I noticed and fixed recently. And that reminded me of the second one, > > which I'd been carrying in my local copy for a long time. > > > > [1/3]: contrib/git-jump: fix greedy regex when matching hunks > > [2/3]: contrib/git-jump: add whitespace-checking mode > > [3/3]: contrib/git-jump: fix typo in README > > These 3 patches look good to me. > > They also made me aware of git-jump's existence and purpose. I think I > shall use this script a lot myself from now on. Yay, now there are at least 2 users. Bug reports and patches very welcome. :) -Peff ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-07-24 15:32 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-07-22 16:27 [PATCH 0/3] minor git-jump improvements Jeff King 2016-07-22 16:28 ` [PATCH 1/3] contrib/git-jump: fix greedy regex when matching hunks Jeff King 2016-07-22 16:29 ` [PATCH 2/3] contrib/git-jump: add whitespace-checking mode Jeff King 2016-07-22 16:35 ` [PATCH v2 " Jeff King 2016-07-22 16:30 ` [PATCH 3/3] contrib/git-jump: fix typo in README Jeff King 2016-07-23 8:52 ` [PATCH 0/3] minor git-jump improvements Johannes Schindelin 2016-07-24 15:32 ` Jeff King
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).