threads / rfc / 28382

RFC patchbash: add --word-diff option to diff auto-completion

Subject: [PATCH/RFC] bash: add --word-diff option to diff auto-completion

## tl;dr

5 messages between Sep 13, 2011 and Sep 16, 2011. Diffs are folded; open one to read it.

replies: 4people: 4as markdown or json

Jonathan Nieder· Sep 13, 2011, 19:14 UTC · lore
From: Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
Date: Tue, 13 Sep 2011 15:24:38 -0300

Add "--word-diff" to diff completion, since this is a common desired option when looking at diffs.

Signed-off-by: Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
---
Hi Gábor,
Here's a patch.  What do you think?

I was thinking it would be nice to complete --word-diff-regex, too, and to be able to do

	git diff --color-words=<TAB>
	git diff --word-diff=<TAB>

but I couldn't find any examples of the latter to crib from, so I've left the patch unmangled except for stealing a patch description from a separate email.

Rodrigo Rosenfeld Rosas wrote:
> I use Thunderbird, but couldn't find all options as instructed in 'git help
> format-patch'.

Indeed, sending patches unmangled seems to be a common difficult step when starting to contribute to projects like linux and git. I wonder if it would make sense to include some sort of patch-sending-reviewing-tweaking-and-receiving tutorial to point to in the documentation.

Thanks for keeping the completion code in good shape. Jonathan

 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to contrib/completion/git-completion.bash +1 −1
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 8648a36..f4aaffe 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1300,7 +1300,7 @@ _git_describe ()
 
 __git_diff_common_options="--stat --numstat --shortstat --summary
 			--patch-with-stat --name-only --name-status --color
-			--no-color --color-words --no-renames --check
+			--no-color --color-words --word-diff --no-renames --check
 			--full-index --binary --abbrev --diff-filter=
 			--find-copies-harder
 			--text --ignore-space-at-eol --ignore-space-change
-- 
1.7.5.4
SZEDER Gábor· Sep 13, 2011, 23:29 UTC · re: Jonathan Nieder · lore

Re: [PATCH/RFC] bash: add --word-diff option to diff auto-completion

Hi,
On Tue, Sep 13, 2011 at 02:14:48PM -0500, Jonathan Nieder wrote:
Show 11 quoted lines
> From: Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
> Date: Tue, 13 Sep 2011 15:24:38 -0300
> 
> Add "--word-diff" to diff completion, since this is a common
> desired option when looking at diffs.
> 
> Signed-off-by: Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
> ---
> Hi Gábor,
> 
> Here's a patch.  What do you think?
Looks obviously good to me, ...
Show 5 quoted lines
> I was thinking it would be nice to complete --word-diff-regex, too,
> and to be able to do
> 
> 	git diff --color-words=<TAB>
> 	git diff --word-diff=<TAB>
... but yeah, there is room for while-at-its ;)

The completion script currently only offers --color-words but not --color-words=. This is sort of OK, because --color-words' parameters are optional. However, in several cases the completion script offers both --option and --option= to indicate that it takes an optional parameter, see e.g.

  diff --dirstat --dirstat-by-file
  commit --untracked-files
  format-patch --thread
  init --shared
  log --decorate

(But we don't do this in all such cases, see e.g. diff --stat --color or log --branches --tags --remotes.)

So I think it's fine to offer both --color-words and --color-words=, and both --word-diff and --word-diff=.

> but I couldn't find any examples of the latter to crib from

I'm not sure what you mean by git diff --color-words=<TAB>, because it takes a regexp. Or is it just too late here and I'm missing something obvious?

Completing the mode for --word-diff=<TAB> is a good idea, but c'mon, there are plenty of examples ;) Have a look at _git_am(), _git_format_patch(), or _git_init() for something easy, and _git_commit(), _git_log(), or _git_notes() for something fancy.

Note that --word-diff= is also valid for log and shortlog, so the same can be done there, too.

Best, Gábor

SZEDER Gábor· Sep 13, 2011, 23:37 UTC · re: SZEDER Gábor · lore

Re: [PATCH/RFC] bash: add --word-diff option to diff auto-completion

On Wed, Sep 14, 2011 at 01:29:41AM +0200, SZEDER Gábor wrote:
Show 10 quoted lines
> Or is it just too late here and I'm missing something
> obvious?
> 
> Completing the mode for --word-diff=<TAB> is a good idea, but c'mon,
> there are plenty of examples ;)  Have a look at _git_am(),
> _git_format_patch(), or _git_init() for something easy, and
> _git_commit(), _git_log(), or _git_notes() for something fancy.
> 
> Note that --word-diff= is also valid for log and shortlog, so the same
> can be done there, too.
Not shortlog, show.  It's definitely too late... ;)
Rodrigo Rosenfeld Rosas· Sep 16, 2011, 15:56 UTC · re: SZEDER Gábor · lore

Re: [PATCH/RFC] bash: add --word-diff option to diff [AND --set-upstream TO push] auto-completion

While on the topic, it would also be interesting to add "--set-upstream" to "git push" autocompletion. Don't you agree?

Cheers, Rodrigo.
Em 13-09-2011 20:37, SZEDER Gábor escreveu:
Show 15 quoted lines
> On Wed, Sep 14, 2011 at 01:29:41AM +0200, SZEDER Gábor wrote:
>> Or is it just too late here and I'm missing something
>> obvious?
>>
>> Completing the mode for --word-diff=<TAB>  is a good idea, but c'mon,
>> there are plenty of examples ;)  Have a look at _git_am(),
>> _git_format_patch(), or _git_init() for something easy, and
>> _git_commit(), _git_log(), or _git_notes() for something fancy.
>>
>> Note that --word-diff= is also valid for log and shortlog, so the same
>> can be done there, too.
>
> Not shortlog, show.  It's definitely too late... ;)
>
>
Jonathan Nieder· Sep 16, 2011, 20:47 UTC · re: Rodrigo Rosenfeld Rosas · lore

Re: [PATCH/RFC] bash: add --word-diff option to diff [AND --set-upstream TO push] auto-completion

Rodrigo Rosenfeld Rosas wrote:
> While on the topic, it would also be interesting to add "--set-upstream" to
> "git push" autocompletion. Don't you agree?
Yes, of course.

← back to recent threads