public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Adam W. Hawks" <awhawks@writeme•com>
To: git@vger•kernel.org
Subject: [JGIT PATCH 1/1] Fix for Repository.stripWorkDir when using partial paths
Date: Tue, 11 Aug 2009 20:48:39 -0400	[thread overview]
Message-ID: <4A821167.6030107@writeme.com> (raw)


>From ef993e633cdcb1dddda5e71db1b62306df7ce83f Mon Sep 17 00:00:00 2001
Date: Tue, 11 Aug 2009 20:02:56 -0400

When you call stripWorkDir with a relative path
you can get a string out of bounds error.

This change fixes that problem by using the absolute paths
of the file instead of its relative name.

Signed-off-by: Adam W. Hawks <awhawks@writeme•com>
---
 .../src/org/spearce/jgit/lib/Repository.java       |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index 468cf4c..a68817b 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -1036,7 +1036,7 @@ public static boolean isValidRefName(final String refName) {
 	 * @return normalized repository relative path
 	 */
 	public static String stripWorkDir(File wd, File f) {
-		String relName = f.getPath().substring(wd.getPath().length() + 1);
+		String relName = f.getAbsolutePath().substring(wd.getPath().length() + 1);
 		relName = relName.replace(File.separatorChar, '/');
 		return relName;
 	}
-- 
1.6.0.2

             reply	other threads:[~2009-08-12  0:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-12  0:48 Adam W. Hawks [this message]
2009-08-12 14:29 ` [JGIT PATCH 1/1] Fix for Repository.stripWorkDir when using partial paths Shawn O. Pearce
2009-08-12 19:47 ` Robin Rosenberg
2009-08-19 12:50   ` [PATCH JGIT] Make Repository.stripWorkDir more robust Jonas Fonseca

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=4A821167.6030107@writeme.com \
    --to=awhawks@writeme$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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