git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] merge: support --strategy '?' for git-completion.bash
Date: Fri, 26 Jan 2018 08:31:42 +0700	[thread overview]
Message-ID: <20180126013142.GA11346@duynguyen.dek-tpc.internal> (raw)
In-Reply-To: <xmqqo9lhai46.fsf@gitster.mtv.corp.google.com>

On Thu, Jan 25, 2018 at 10:49:45AM -0800, Junio C Hamano wrote:
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
> 
> > Bash completion support gets the list of available strategies with a
> > grep and sed trick which does not work on non-C locale since the anchor
> > string is translated and it does not cover custom strategies either.
> >
> > Let's do it a better way and make git-merge provide all available
> > strategies in machine-readable form.
> >
> > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> > ---
> >  Another, perhaps better, option is add "git merge --list-strategies".
> >  It requires some code movement, so I'll try with a simpler approach
> >  first.
> 
> If you run the probing "merge -s help" under C locale, that would
> just be a one-liner, no ;-)  I.e.

That was my first choice but I was worried that it failed to catch
custom strategies which are preceded with a different anchor string
"Available custom strategies are:".

I didn't look carefully at those sed magic. But it looks like it
correctly handles this case too. So v2 follows below. It still feels
dirty to do this kind of text manipulation though. But that can wait.

-- 8< --
Subject: [PATCH] completion: fix completing merge strategies on non-C locales

The anchor string "Available strategies are:" is translatable so
__git_list_merge_strategies may fail to collect available strategies
from 'git merge' on non-C locales. Force C locale on this command.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3683c772c5..88813e9124 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -594,7 +594,7 @@ __git_is_configured_remote ()
 
 __git_list_merge_strategies ()
 {
-	git merge -s help 2>&1 |
+	LANG=C LC_ALL=C git merge -s help 2>&1 |
 	sed -n -e '/[Aa]vailable strategies are: /,/^$/{
 		s/\.$//
 		s/.*://
-- 
2.16.1.196.g4f5118c359



-- 8< --

  reply	other threads:[~2018-01-26  1:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-25  9:40 [PATCH] merge: support --strategy '?' for git-completion.bash Nguyễn Thái Ngọc Duy
2018-01-25 18:49 ` Junio C Hamano
2018-01-26  1:31   ` Duy Nguyen [this message]
2018-01-26 17:47     ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180126013142.GA11346@duynguyen.dek-tpc.internal \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
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 NNTP newsgroup(s).