diff mbox series

[maintainer-tools,v2,1/4] dim: allow git_dir to specify arbitrary work directory

Message ID 20181218103016.8070-2-a.hajda@samsung.com (mailing list archive)
State New, archived
Headers show
Series dim: fix git directory evaluation | expand

Commit Message

Andrzej Hajda Dec. 18, 2018, 10:30 a.m. UTC
git_dir function returns git directory for current working directory.
Allowing specifying any directory allows to reuse it more widely.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 dim | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/dim b/dim
index 70939ff..df66c58 100755
--- a/dim
+++ b/dim
@@ -565,10 +565,12 @@  function rr_cache_dir
 
 function git_dir
 {
-	if [ -d $PWD/.git ] ; then
-		echo $PWD/.git
+	local dir=${1:-$PWD}
+
+	if [ -d $dir/.git ] ; then
+		echo $dir/.git
 	else
-		cut -d ' ' -f 2 < $PWD/.git
+		cut -d ' ' -f 2 < $dir/.git
 	fi
 }