+
Skip to content

(2nd revision) #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ __gitdir ()
__git_ps1_show_upstream ()
{
local key value
local svn_remote svn_url_pattern count n
local upstream=git legacy="" verbose=""
local count
local upstream=git upstream_path="" legacy="" verbose=""

svn_remote=()
# get some config options from git-config
Expand All @@ -110,8 +110,6 @@ __git_ps1_show_upstream ()
fi
;;
svn-remote.*.url)
svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value"
svn_url_pattern+="\\|$value"
upstream=svn+git # default upstream is SVN if available, else git
;;
esac
Expand All @@ -130,26 +128,18 @@ __git_ps1_show_upstream ()
case "$upstream" in
git) upstream="@{upstream}" ;;
svn*)
# get the upstream from the "git-svn-id: ..." in a commit message
# (git-svn uses essentially the same procedure internally)
local svn_upstream=($(git 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 ]}
svn_upstream=${svn_upstream%@*}
local n_stop="${#svn_remote[@]}"
for ((n=1; n <= n_stop; n++)); do
svn_upstream=${svn_upstream#${svn_remote[$n]}}
done

if [[ -z "$svn_upstream" ]]; then
# default branch name for checkouts with no layout:
upstream=${GIT_SVN_ID:-git-svn}
else
upstream=${svn_upstream#/}
fi
elif [[ "svn+git" = "$upstream" ]]; then
upstream="@{upstream}"
upstream_path="$(git config --get-regexp 'svn-remote.*(fetch|tags|branches)$' |
cut -d' ' -f2 | cut -d: -f1)"
if [[ -z "$upstream_path" ]]
then
# default branch name for checkouts with no layout:
upstream=${GIT_SVN_ID:-git-svn}
else
upstream="$(git log -1 --pretty=format:"%B" --first-parent \
--grep=git-svn-id HEAD |
grep -oE '(tags/)?[^/]+@' --color=never |
tr -d "@")"
[ -n "$upstream" ] || upstream="@{upstream}"
fi
;;
esac
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载