git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH v2 2/3] contrib/git-jump: add whitespace-checking mode
Date: Fri, 22 Jul 2016 12:35:19 -0400	[thread overview]
Message-ID: <20160722163518.GA14600@sigill.intra.peff.net> (raw)
In-Reply-To: <20160722162945.GB14080@sigill.intra.peff.net>

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


  reply	other threads:[~2016-07-22 16:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Jeff King [this message]
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

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=20160722163518.GA14600@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    /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).