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

Submitted by Andrzej Hajda on Dec. 14, 2018, 1:38 p.m.

Details

Message ID 20181214133852.19665-2-a.hajda@samsung.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in DRI devel

Not browsing as part of any series.

Commit Message

Andrzej Hajda Dec. 14, 2018, 1:38 p.m.
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>
---
 dim | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

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
 }