Skip to content

Commit af1df49

Browse files
authored
Merge pull request magicmonty#409 from ogr3/update_old_gitstatus
Update old gitstatus to support remote username
2 parents 2e1a419 + edf492a commit af1df49

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

gitstatus_pre-1.7.10.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ if [ -z "${__GIT_PROMPT_DIR}" ]; then
1919
__GIT_PROMPT_DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
2020
fi
2121

22+
if [[ "${__GIT_PROMPT_WITH_USERNAME_AND_REPO}" == "1" ]]; then
23+
# returns "user/repo" from remote.origin.url git variable
24+
#
25+
# supports urls:
26+
# https://[email protected]/user/repo.git
27+
# https://github.com/user/repo.git
28+
# [email protected]:user/repo.git
29+
#
30+
remote_url=$(git config --get remote.origin.url | sed 's|^.*//||; s/.*@//; s/[^:/]\+[:/]//; s/.git$//')
31+
else
32+
remote_url='.'
33+
fi
34+
2235
gitsym=$( git symbolic-ref HEAD 2>/dev/null )
2336

2437
#If exit status OK, we have a branch
@@ -99,6 +112,7 @@ else
99112
fi
100113
else
101114
remote='_NO_REMOTE_TRACKING_'
115+
remote_url='.'
102116
unset upstream
103117
fi
104118
fi
@@ -111,9 +125,10 @@ if [[ -z "$upstream" ]] ; then
111125
upstream='^'
112126
fi
113127

114-
printf "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" \
128+
printf "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" \
115129
"$branch" \
116130
"$remote" \
131+
"$remote_url" \
117132
"$upstream" \
118133
$num_staged \
119134
$num_conflicts \

0 commit comments

Comments
 (0)