[PATCH] Explain "Not a git repository: '.git'".

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andy Parkins noticed that the error message some "whole tree"
oriented commands emit is stated misleadingly when they refused
to run from a subdirectory.

We could probably allow some of them to work from a subdirectory
but that is a semantic change that could have unintended side
effects, so let's start at first by rewording the error message
to be easier to read without doing anything else to be safe.

Signed-off-by: Junio C Hamano <junkio@xxxxxxx>
---

 Andy Parkins <andyparkins@xxxxxxxxx> writes:

 > Minor thing: git-rebase, git-cherry-pick and git-pull (and
 > presumably git-merge) all need to be the repository root to
 > work.  If that is intentional, a better message than "fatal:
 > Not a git repository: '.git'" would be appropriate.
 >
 > For me, I'd prefer that they worked in subdirectories.  I do
 > all almost all development in "src/" and having to change up a
 > directory just to run git commands is inconvenient.

 Thanks; let's do this for now.

 git-sh-setup.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 4a02b38..57f7f77 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -60,7 +60,11 @@ esac
 if [ -z "$SUBDIRECTORY_OK" ]
 then
 	: ${GIT_DIR=.git}
-	GIT_DIR=$(GIT_DIR="$GIT_DIR" git-rev-parse --git-dir) || exit
+	GIT_DIR=$(GIT_DIR="$GIT_DIR" git-rev-parse --git-dir) || {
+		exit=$?
+		echo >&2 "You need to run this command from the toplevel of the working tree."
+		exit $exit
+	}
 else
 	GIT_DIR=$(git-rev-parse --git-dir) || exit
 fi
-- 
1.5.0.rc1.g397d

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]