Thread (6 messages) 6 messages, 4 authors, 2016-06-15
DORMANTno replies

[PATCH] Change to the repository's root directory if needed.

From: <hidden>
Date: 2016-06-15 22:42:49
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Steven Grimm <redacted>
---

Or try this instead. It seems to work in my limited testing, but it's
possible this breaks something somewhere. The only weird thing here
is that if, e.g., you have a file foo.c in the top-level directory and
you run "git pull" from a subdirectory, you'll see a message indicating
that "foo.c" was updated, implying that it's updating that file in the
current directory. (Output about files in subdirectories, to my eye,
feels less ambiguous in that respect.) But after running with this for
just a few minutes, I'm willing to put up with that in exchange for
not having to manually cd.

 git-sh-setup.sh |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 4a02b38..d1c78c4 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -59,8 +59,13 @@ esac
 # Make sure we are in a valid repository of a vintage we understand.
 if [ -z "$SUBDIRECTORY_OK" ]
 then
-	: ${GIT_DIR=.git}
-	GIT_DIR=$(GIT_DIR="$GIT_DIR" git-rev-parse --git-dir) || exit
+	GIT_DIR=$(git-rev-parse --git-dir) || exit
+	if [ "$GIT_DIR" != ".git" -a "$(basename \"$GIT_DIR\")" = ".git" ]
+	then
+		# In a subdirectory of a non-bare repository; move to root dir
+		cd "`dirname \"$GIT_DIR\"`" || \
+			die "Can't change to repository root directory"
+	fi
 else
 	GIT_DIR=$(git-rev-parse --git-dir) || exit
 fi
-- 
1.5.0.rc0.g4083
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help