Git development
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: git@vger.kernel.org, gitster@pobox.com
Subject: [PATCH] Fix make_absolute_path() for parameters without a slash
Date: Sun, 2 Mar 2008 07:17:49 +0000 (GMT)	[thread overview]
Message-ID: <alpine.LSU.1.00.0803020717060.22527@racer.site> (raw)


When passing "xyz" to make_absolute_path(), make_absolute_path()
erroneously tried to chdir("xyz"), and then append "/xyz".  Instead,
skip the chdir() completely when no slash was found.

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

	I should add a test, but I am simply too tired now.  Will do so 
	tomorrow.

 path.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/path.c b/path.c
index 4260952..bf3e469 100644
--- a/path.c
+++ b/path.c
@@ -311,8 +311,10 @@ const char *make_absolute_path(const char *path)
 			if (last_slash) {
 				*last_slash = '\0';
 				last_elem = xstrdup(last_slash + 1);
-			} else
+			} else {
+				*buf = '\0';
 				last_elem = xstrdup(buf);
+			}
 		}
 
 		if (*buf) {
-- 
1.5.4.3.446.gbe8932


             reply	other threads:[~2008-03-02  7:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-02  7:17 Johannes Schindelin [this message]
2008-03-02  7:31 ` [PATCH] Fix make_absolute_path() for parameters without a slash Johannes Schindelin
2008-03-02  7:40   ` Johannes Schindelin

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=alpine.LSU.1.00.0803020717060.22527@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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