Mageia Bugzilla – Attachment 14321 Details for
Bug 32798
ksh-compatibility for …/completion/git-prompt.sh
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
git-prompt.sh.patch (created by diff -u)
git-prompt.sh.patch (text/plain), 2.55 KB, created by
Elmar Stellnberger
on 2024-01-31 21:59:54 CET
(
hide
)
Description:
git-prompt.sh.patch (created by diff -u)
Filename:
MIME Type:
Creator:
Elmar Stellnberger
Created:
2024-01-31 21:59:54 CET
Size:
2.55 KB
patch
obsolete
>--- /aaa/usr/share/doc/git-core/contrib/completion/git-prompt.sh 2024-01-31 18:23:30.694388715 +0100 >+++ /bbb/usr/share/doc/git-core/contrib/completion/git-prompt.sh 2024-01-31 21:15:22.752417534 +0100 >@@ -107,6 +107,8 @@ > # GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the > # repository level by setting bash.hideIfPwdIgnored to "false". > >+ShellType="${BASH_VERSION:+bash}${KSH_VERSION:+ksh}" >+ > # check whether printf supports -v > __git_printf_supports_v= > printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1 >@@ -119,10 +121,10 @@ > local svn_remote svn_url_pattern count n > local upstream_type=git legacy="" verbose="" name="" > >- svn_remote=() >+ unset svn_remote > # get some config options from git-config >- local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')" >- while read -r key value; do >+ git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | \ >+ tr '\0\n' '\n ' | while read -r key value; do > case "$key" in > bash.showupstream) > GIT_PS1_SHOWUPSTREAM="$value" >@@ -137,7 +139,7 @@ > upstream_type=svn+git # default upstream type is SVN if available, else git > ;; > esac >- done <<< "$output" >+ done > > # parse configuration values > local option >@@ -157,13 +159,22 @@ > # 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 \ >- --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) >+ local prm_log="git log --first-parent -1" >+ local prm_grep="^git-svn-id: \(${svn_url_pattern#??}\)" >+ exec 9>/dev/null >+ echo "-$BASH_VERSION-" >$(tty) >+ if [[ "$ShellType" = "bash" ]]; then >+ svn_upstream=($(git log $prm_log --grep="$prm_grep" >&9)) >+ else # "ksh" >+ set -A svn_upstream -- $(git log $prm_log --grep="$prm_grep" >&9) >+ fi >+ exec 9>&- > if [[ 0 -ne ${#svn_upstream[@]} ]]; then > svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]} > svn_upstream=${svn_upstream%@*} > local n_stop="${#svn_remote[@]}" >- for ((n=1; n <= n_stop; n++)); do >+ #for ((n=1; n <= n_stop; n++)); do >+ for n in $(seq $n_stop); do > svn_upstream=${svn_upstream#${svn_remote[$n]}} > done > >@@ -512,7 +523,7 @@ > > local conflict="" # state indicator for unresolved conflicts > if [[ "${GIT_PS1_SHOWCONFLICTSTATE}" == "yes" ]] && >- [[ $(git ls-files --unmerged 2>/dev/null) ]]; then >+ [[ -n "$(git ls-files --unmerged 2>/dev/null)" ]]; then > conflict="|CONFLICT" > fi >
--- /aaa/usr/share/doc/git-core/contrib/completion/git-prompt.sh 2024-01-31 18:23:30.694388715 +0100 +++ /bbb/usr/share/doc/git-core/contrib/completion/git-prompt.sh 2024-01-31 21:15:22.752417534 +0100 @@ -107,6 +107,8 @@ # GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the # repository level by setting bash.hideIfPwdIgnored to "false". +ShellType="${BASH_VERSION:+bash}${KSH_VERSION:+ksh}" + # check whether printf supports -v __git_printf_supports_v= printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1 @@ -119,10 +121,10 @@ local svn_remote svn_url_pattern count n local upstream_type=git legacy="" verbose="" name="" - svn_remote=() + unset svn_remote # get some config options from git-config - local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')" - while read -r key value; do + git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | \ + tr '\0\n' '\n ' | while read -r key value; do case "$key" in bash.showupstream) GIT_PS1_SHOWUPSTREAM="$value" @@ -137,7 +139,7 @@ upstream_type=svn+git # default upstream type is SVN if available, else git ;; esac - done <<< "$output" + done # parse configuration values local option @@ -157,13 +159,22 @@ # 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 \ - --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) + local prm_log="git log --first-parent -1" + local prm_grep="^git-svn-id: \(${svn_url_pattern#??}\)" + exec 9>/dev/null + echo "-$BASH_VERSION-" >$(tty) + if [[ "$ShellType" = "bash" ]]; then + svn_upstream=($(git log $prm_log --grep="$prm_grep" >&9)) + else # "ksh" + set -A svn_upstream -- $(git log $prm_log --grep="$prm_grep" >&9) + fi + exec 9>&- if [[ 0 -ne ${#svn_upstream[@]} ]]; then svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]} svn_upstream=${svn_upstream%@*} local n_stop="${#svn_remote[@]}" - for ((n=1; n <= n_stop; n++)); do + #for ((n=1; n <= n_stop; n++)); do + for n in $(seq $n_stop); do svn_upstream=${svn_upstream#${svn_remote[$n]}} done @@ -512,7 +523,7 @@ local conflict="" # state indicator for unresolved conflicts if [[ "${GIT_PS1_SHOWCONFLICTSTATE}" == "yes" ]] && - [[ $(git ls-files --unmerged 2>/dev/null) ]]; then + [[ -n "$(git ls-files --unmerged 2>/dev/null)" ]]; then conflict="|CONFLICT" fi
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 32798
:
14320
| 14321