git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Scott R Parish <srp@srparish.net>
Cc: git@vger.kernel.org, spearce@spearce.org, gitster@pobox.com
Subject: [PATCH] Deduce exec_path also from calls to git with a relative path
Date: Sat, 20 Oct 2007 08:21:34 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0710200818410.25221@racer.site> (raw)
In-Reply-To: <20071020064617.GC2237@srparish.net>


There is already logic in the git wrapper to deduce the exec_path from
argv[0], when the git wrapper was called with an absolute path.  Extend
that logic to handle relative paths as well.

For example, when you call "../../hello/world/git", it will not turn
"../../hello/world" into an absolute path, and use that.

Initial implementation by Scott R Parish.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	On Fri, 19 Oct 2007, Scott R Parish wrote:

	>  Signed-off-by: Scott R Parish <srp@srparish.net>

	That is a little short for a commit message ;-)

	>  git.c |   35 +++++++++++++++++++++++++++++++++--
	>  1 files changed, 33 insertions(+), 2 deletions(-)

	I had commented on this before.  Probably I did a very bad job 
	at explaining things, so hopefully this is better:

 git.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/git.c b/git.c
index d7c6bca..1dad764 100644
--- a/git.c
+++ b/git.c
@@ -414,13 +414,14 @@ int main(int argc, const char **argv)
 	/*
 	 * Take the basename of argv[0] as the command
 	 * name, and the dirname as the default exec_path
-	 * if it's an absolute path and we don't have
-	 * anything better.
+	 * if we don't have anything better.
 	 */
 	if (slash) {
 		*slash++ = 0;
 		if (*cmd == '/')
 			exec_path = cmd;
+		else
+			exec_path = xstrdup(make_absolute_path(cmd));
 		cmd = slash;
 	}
 
-- 
1.5.3.4.1287.g8b31e

  reply	other threads:[~2007-10-20  7:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-20  6:46 [PATCH] If git is ran with a relative path, try building an absolute exec_path from it Scott R Parish
2007-10-20  7:21 ` Johannes Schindelin [this message]
2007-10-20 12:25   ` [PATCH] Deduce exec_path also from calls to git with a relative path David Brown
2007-10-20 21:25     ` Johannes Schindelin
  -- strict thread matches above, loose matches on Subject: below --
2007-10-20  8:13 Scott R Parish
2007-10-20 21:31 ` Johannes Schindelin
2007-10-20 23:04   ` Scott Parish

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=Pine.LNX.4.64.0710200818410.25221@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=spearce@spearce.org \
    --cc=srp@srparish.net \
    /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).