Re: [PATCH v4 1/3] completion: no-op refactoring of diff completion

Elijah Newren <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <CABPp-BHhNHBN0Mt0LVjGEcNL_y7mad7rS6NRX6p14ELrRD-+bg@mail.gmail.com>
On Thu, Aug 6, 2026 at 6:38 PM Junio C Hamano <[email protected]> wrote:
>
> The "git diff" completion function punts very early when it sees
> "--" on the command line, since it is a sign that options or
> revisions can appear and the current completion does not need to do
> anything "git diff" specific. By returning, it lets Bash default
> action that completes the names of the files in $PWD to kick in.
>
> In preparation for the next step to change what happens when we
> "punt", arrange the code flow to avoid this early return.  The
> behaviour at this step is unchanged, but the control flow just
> falls straight to the end.
>
> Signed-off-by: Junio C Hamano <[email protected]>
> ---
>  contrib/completion/git-completion.bash | 61 ++++++++++++++------------
>  1 file changed, 33 insertions(+), 28 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index e875787710..ccd3b2a372 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1947,35 +1947,40 @@ __git_diff_difftool_options="--cached --staged
>
>  _git_diff ()
>  {
[...]
> +       if ! __git_has_doubledash; then
> +               case "$cur" in
> +               --diff-algorithm=*)
> +                       __gitcomp "$__git_diff_algorithms" \
> +                               "" "${cur##--diff-algorithm=}"
> +                       return
>                 ;;

The refactor in this commit is a faithful no-op -- every arm got
re-indented by one tab as expected.  One tiny slip, though: this first
case's ";;" didn't get the extra tab that every other arm received.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.