Skip to content
Browse files

git-get commands for paths to root of repository and relative CWD

  • Loading branch information...
1 parent 574c23e commit c4825e8ae796964c118c947d8ba6ebe15ba41d17 @mjdominus committed
Showing with 14 additions and 0 deletions.
  1. +14 −0 git-get
View
14 git-get
@@ -14,6 +14,20 @@ $what =~ tr/-/_/;
}
}
+sub repo_rootdir_absolute {
+ _run("git rev-parse --show-toplevel");
+}
+
+sub repo_rootdir_relative {
+ my $rel = _run("git rev-parse --show-cdup");
+ $rel =~ s{/$}{};
+ $rel eq "" ? "." : $rel;
+}
+
+sub pwd_relative {
+ _run("git rev-parse --show-prefix");
+}
+
sub current_branch_name {
if (_head_detached()) { return "" }
_run("git rev-parse --symbolic-full-name --abbrev-ref HEAD");

0 comments on commit c4825e8

Please sign in to comment.
Something went wrong with that request. Please try again.