Permalink
Browse files

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

  • Loading branch information...
1 parent b8d85d5 commit 4e853a6625957c89696cafac7b86433fe2f9b5cf @mjdominus committed Mar 17, 2013
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 4e853a6

Please sign in to comment.