Re: [JGIT PATCH 1/1] Fix for Repository.stripWorkDir when using partial paths

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

 



"Adam W. Hawks" <awhawks@xxxxxxxxxxx> wrote:
> 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.

Except it made the existing test suite fail, badly.  I'm counting
7 errors and 28 test failures as a result of applying this patch.
 
> 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;
>  	}

-- 
Shawn.
--
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]