git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Sep 13, 2011, 23:29 UTC
Message-ID
<20110913232941.GC2078@goldbirke>
In-Reply-To
<20110913191448.GC14917@elie>
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

Previous: Jonathan NiederNext: SZEDER Gábor
Message 2 of 5 in “bash: add --word-diff option to diff auto-completion”
  1. bash: add --word-diff option to diff auto-completionJonathan Nieder, Sep 13, 2011
  2. SZEDER GáborSep 13, 2011
  3. SZEDER GáborSep 13, 2011
  4. Rodrigo Rosenfeld RosasSep 16, 2011
  5. Jonathan NiederSep 16, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.