git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Richard Soderberg <rsoderberg@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: git-prompt.sh incompatible with non-basic global grep.patternType
Date: Tue, 19 Jul 2016 13:24:19 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1607191323010.3472@virtualbox> (raw)
In-Reply-To: <CAEvc1UQvXKtQCXvCmt-774A84--bkK-sb94BtFeqDDr0Gsf7qw@mail.gmail.com>

Hi Richard,

On Mon, 18 Jul 2016, Richard Soderberg wrote:

> Hi, I wanted to report something interesting that I found while tracing
> a severe slowdown in git-prompt.sh.
> 
> https://github.com/git/git/commit/6d158cba282f22fa1548af1188f78042fed30aed#diff-f37c4f4a898819f0ca4b5ff69e81d4d9R141
> 
> Way back in this commit, someone added a useful chunk of code that works
> perfectly with svn+ssh:// URLs under basic regexes:
> 
> + local svn_upstream=($(git log --first-parent -1 \ +
> --grep="^git-svn-id: \(${svn_url_pattern:2}\)" 2>/dev/null))
> 
> However, if I switch over to Perl regexes (or Extended):
> 
> git config --global grep.patternType perl
> 
> Then the command runs for one wall clock second and shows incorrect
> results on my repository. I eventually traced this to an issue with the
> regular expression provided, assuming the svn repository url is
> "svn+ssh://...":
> 
> git log ... --grep="^git-svn-id: \(svn+ssh://...\)" 2>/dev/null
> 
> The + sign isn't escaped in git-prompt.sh, which under non-basic regexes
> causes the match to fail entirely.
> 
>  - R.
> 
> ps. git log --basic-regexp does not fix the issue, as for unknown
> reasons (I'll start another thread) the command-line option doesn't
> override grep.patternType.

Maybe this helps?

-- snipsnap --
diff --git a/contrib/completion/git-prompt.sh
b/contrib/completion/git-prompt.sh
index 97eacd7..74be907 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -143,7 +143,7 @@ __git_ps1_show_upstream ()
 		# get the upstream from the "git-svn-id: ..." in a commit
 		# message
 		# (git-svn uses essentially the same procedure internally)
 		local -a svn_upstream
-		svn_upstream=($(git log --first-parent -1 \
+		svn_upstream=($(git -c grep.patternType=default log --first-parent -1 \
 					--grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
 		if [[ 0 -ne ${#svn_upstream[@]} ]]; then
 			svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]}


  reply	other threads:[~2016-07-19 11:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 22:56 git-prompt.sh incompatible with non-basic global grep.patternType Richard Soderberg
2016-07-19 11:24 ` Johannes Schindelin [this message]
2016-07-19 14:14   ` Richard Soderberg
2016-07-19 14:35     ` Johannes Schindelin
2016-07-20 13:42 ` Jeff King
2016-07-20 20:10   ` Junio C Hamano
2016-07-20 20:52     ` Jeff King
2016-07-22 19:21       ` Junio C Hamano
2016-07-22 19:28         ` Jeff King
2016-07-22 19:51           ` Junio C Hamano
2016-07-22 20:05             ` Jeff King
2016-07-22 20:33               ` Junio C Hamano
2016-07-22 23:28         ` Eric Sunshine
2016-07-25 16:16           ` 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=alpine.DEB.2.20.1607191323010.3472@virtualbox \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=rsoderberg@gmail.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).