Skip to contentSkip to conversation

bash: add --word-diff option to diff auto-completion

PATCH/RFC Jonathan Nieder 4 participants 5 messages Jun 15, 2016 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 20110913165847.GB11076@elie

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

From: Rodrigo Rosenfeld Rosas <[email protected]>
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.

---
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.

Quoted 2 lines · Rodrigo Rosenfeld Rosas

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(-)
contrib/completion/git-completion.bash +1 -1
index 8648a36..f4aaffe 100755
@@ -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
Signature · 1 line
1.7.5.4
#4 lore raw

Hi,

Quoted 11 lines · Jonathan Nieder

From: Rodrigo Rosenfeld Rosas <[email protected]>
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.

---
Hi Gábor,

Here's a patch. What do you think?

Looks obviously good to me, ...

Quoted 5 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=.

Quoted 1 line

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

#5 lore raw
Quoted 10 lines · SZEDER Gábor

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... ;)

#6 lore raw

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:

Quoted 15 lines · SZEDER Gábor
Quoted 10 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... ;)

#7 lore raw

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

Quoted 2 lines · Rodrigo Rosenfeld Rosas

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

Yes, of course.