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

Re: git-prompt.sh incompatible with non-basic global grep.patternType

From
RSRichard Soderberg <rsoderberg@gmail.com>
Date
Jul 19, 2016, 14:14 UTC
Message-ID
<CAEvc1UT_gmkmOjhs8PMH+vBRE1gku5yYRPhPfOL_B_vyeh23_g@mail.gmail.com>
In-Reply-To
<alpine.DEB.2.20.1607191323010.3472@virtualbox>

Aha! Yes, this works precisely as intended: the prompt works correctly, and quickly, with this change in place.

 - R.

On Tue, Jul 19, 2016 at 4:24 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 54 quoted lines
> 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]}
>
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 3 of 14 in “git-prompt.sh incompatible with non-basic global grep.patternType”
  1. Richard SoderbergJul 18, 2016
  2. Johannes SchindelinJul 19, 2016
  3. Richard SoderbergJul 19, 2016
  4. Johannes SchindelinJul 19, 2016
  5. Jeff KingJul 20, 2016
  6. Junio C HamanoJul 20, 2016
  7. Jeff KingJul 20, 2016
  8. Junio C HamanoJul 22, 2016
  9. Jeff KingJul 22, 2016
  10. Junio C HamanoJul 22, 2016
  11. Jeff KingJul 22, 2016
  12. Junio C HamanoJul 22, 2016
  13. Eric SunshineJul 22, 2016
  14. Junio C HamanoJul 25, 2016

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.