git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Fonseca <fonseca@diku.dk>
To: Petr Baudis <pasky@ucw.cz>
Cc: git@vger.kernel.org
Subject: [PATCH] cg-Xlib: use git-rev-parse to locate .git dir and set relpath
Date: Sun, 27 Nov 2005 16:55:21 +0100	[thread overview]
Message-ID: <20051127155521.GA9558@diku.dk> (raw)

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
diff --git a/cg-Xlib b/cg-Xlib
index dedbb62..e3c365f 100755
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -502,16 +502,10 @@ fi
 
 _git=${GIT_DIR:-.git}
 if [ ! "$_git_repo_unneeded" ] && [ ! "$GIT_DIR" ] && [ ! -d $_git ]; then
-	rootpath=.
-	# while not /
-	while [ ! -d $rootpath/.git ] && [ "$(stat -c %i $rootpath)" != "$(stat -c %i $rootpath/..)" ]; do
-		rootpath=../$rootpath
-	done
-	if [ -d $rootpath/.git ]; then
-		mainpath="$(echo "$(pwd)/$rootpath" | normpath)"
-		_git_relpath=$(pwd)/
-		export _git_relpath=${_git_relpath:$((${#mainpath}+1))}
-		cd "$rootpath"
+	_git_abs_path="$(git-rev-parse --git-dir 2>/dev/null)"
+	if [ -d "$_git_abs_path" ]; then
+		export _git_relpath="$(git-rev-parse --show-prefix)"
+		cd "$_git_abs_path/.."
 	fi
 fi
 _git_objects="${GIT_OBJECT_DIRECTORY:-$_git/objects}"

-- 
Jonas Fonseca

                 reply	other threads:[~2005-11-27 15:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051127155521.GA9558@diku.dk \
    --to=fonseca@diku.dk \
    --cc=git@vger.kernel.org \
    --cc=pasky@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).