use unix paths for dir tests and prefer PathFormat…
[LibreOffice.git] / bin / git-ps1
blob8a09800911638f07b07a58fb0f31ade1b265582c
1 #!/usr/bin/env bash
2 r=
3 b=
4 g="$(git rev-parse --git-dir 2>/dev/null)"
6 if [ -n "$g" ]; then
7 if [ -d "$g/../.dotest" ]
8 then
9 if test -f "$g/../.dotest/rebasing"
10 then
11 r="|REBASE"
12 elif test -f "$g/../.dotest/applying"
13 then
14 r="|AM"
15 else
16 r="|AM/REBASE"
18 b="$(git symbolic-ref HEAD 2>/dev/null)"
19 elif [ -f "$g/.dotest-merge/interactive" ]
20 then
21 r="|REBASE-i"
22 b="$(cat "$g/.dotest-merge/head-name")"
23 elif [ -d "$g/.dotest-merge" ]
24 then
25 r="|REBASE-m"
26 b="$(cat "$g/.dotest-merge/head-name")"
27 elif [ -f "$g/MERGE_HEAD" ]
28 then
29 r="|MERGING"
30 b="$(git symbolic-ref HEAD 2>/dev/null)"
31 else
32 if [ -f "$g/BISECT_LOG" ]
33 then
34 r="|BISECTING"
36 if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
37 then
38 if ! b="$(git describe --exact-match HEAD 2>/dev/null)"
39 then
40 b="$(cut -c1-7 "$g/HEAD")..."
45 if [ -n "$1" ]; then
46 printf "$1" "${b##refs/heads/}$r"
47 else
48 printf "%s" "${b##refs/heads/}$r"
50 else
51 printf "not-in-git"