mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
25 lines
354 B
Bash
Executable file
25 lines
354 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
git_root() {
|
|
git rev-parse --show-toplevel
|
|
}
|
|
|
|
# get the relative path of current path according to root of repo
|
|
git_root_relative() {
|
|
git rev-parse --show-prefix
|
|
}
|
|
|
|
if test $# -eq 0; then
|
|
git_root
|
|
else
|
|
case "$1" in
|
|
-r|--relative)
|
|
git_root_relative
|
|
;;
|
|
*)
|
|
git_root
|
|
;;
|
|
esac
|
|
fi
|
|
|