git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH JGIT] Ensure created test repositories use canonical paths
@ 2009-08-19 13:18 Jonas Fonseca
  2009-08-20 22:35 ` Robin Rosenberg
  0 siblings, 1 reply; 4+ messages in thread
From: Jonas Fonseca @ 2009-08-19 13:18 UTC (permalink / raw)
  To: Robin Rosenberg, Shawn O. Pearce; +Cc: git

Fixes breakage in the RepositoryCacheTest when running tests using:

	mvn -f ./jgit-maven/jgit/pom.xml test

which in turn will lead to test repositories using paths, such as:

	/path/to/jgit/./jgit-maven/jgit/trash/trash1250647279819.186/.git

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
 .../org/spearce/jgit/lib/RepositoryTestCase.java   |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java
index b1adde9..d1aef78 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java
@@ -217,7 +217,7 @@ public void setUp() throws Exception {
 		final String name = getClass().getName() + "." + getName();
 		recursiveDelete(trashParent, true, name, false); // Cleanup old failed stuff
 		trash = new File(trashParent,"trash"+System.currentTimeMillis()+"."+(testcount++));
-		trash_git = new File(trash, ".git");
+		trash_git = new File(trash, ".git").getCanonicalFile();
 		if (shutdownhook == null) {
 			shutdownhook = new Thread() {
 				@Override
@@ -307,7 +307,7 @@ protected Repository createNewEmptyRepo() throws IOException {
 	protected Repository createNewEmptyRepo(boolean bare) throws IOException {
 		final File newTestRepo = new File(trashParent, "new"
 				+ System.currentTimeMillis() + "." + (testcount++)
-				+ (bare ? "" : "/") + ".git");
+				+ (bare ? "" : "/") + ".git").getCanonicalFile();
 		assertFalse(newTestRepo.exists());
 		final Repository newRepo = new Repository(newTestRepo);
 		newRepo.create();
-- 
1.6.4.rc3.195.g2b05f

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH JGIT] Ensure created test repositories use canonical paths
  2009-08-19 13:18 [PATCH JGIT] Ensure created test repositories use canonical paths Jonas Fonseca
@ 2009-08-20 22:35 ` Robin Rosenberg
  2009-08-22  3:32   ` Jonas Fonseca
  0 siblings, 1 reply; 4+ messages in thread
From: Robin Rosenberg @ 2009-08-20 22:35 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: Shawn O. Pearce, git

onsdag 19 augusti 2009 15:18:11 skrev Jonas Fonseca <fonseca@diku.dk>:
> Fixes breakage in the RepositoryCacheTest when running tests using:
> 
> 	mvn -f ./jgit-maven/jgit/pom.xml test
> 
> which in turn will lead to test repositories using paths, such as:
> 
> 	/path/to/jgit/./jgit-maven/jgit/trash/trash1250647279819.186/.git
> 
> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
> ---
>  .../org/spearce/jgit/lib/RepositoryTestCase.java   |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java
> index b1adde9..d1aef78 100644
> --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java
> +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java
> @@ -217,7 +217,7 @@ public void setUp() throws Exception {
>  		final String name = getClass().getName() + "." + getName();
>  		recursiveDelete(trashParent, true, name, false); // Cleanup old failed stuff
>  		trash = new File(trashParent,"trash"+System.currentTimeMillis()+"."+(testcount++));
> -		trash_git = new File(trash, ".git");
> +		trash_git = new File(trash, ".git").getCanonicalFile();
>  		if (shutdownhook == null) {
>  			shutdownhook = new Thread() {
>  				@Override
> @@ -307,7 +307,7 @@ protected Repository createNewEmptyRepo() throws IOException {
>  	protected Repository createNewEmptyRepo(boolean bare) throws IOException {
>  		final File newTestRepo = new File(trashParent, "new"
>  				+ System.currentTimeMillis() + "." + (testcount++)
> -				+ (bare ? "" : "/") + ".git");
> +				+ (bare ? "" : "/") + ".git").getCanonicalFile();
>  		assertFalse(newTestRepo.exists());
>  		final Repository newRepo = new Repository(newTestRepo);
>  		newRepo.create();

We use getCanonicalFile here and Repository.gitDir  is initialized with getAbsoluteDir. Does this work on all platforms?
Seems linux normalized things when you do things like, but I'm not sure that happens everywhere.

ln -s JGIT x;cd x;pwd;jev 'System.out.println(System.getProperty("user.dir"));'
/home/me/SW/x
/home/me/SW/JGIT


-- robin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH JGIT] Ensure created test repositories use canonical paths
  2009-08-20 22:35 ` Robin Rosenberg
@ 2009-08-22  3:32   ` Jonas Fonseca
  2009-08-22 10:15     ` Robin Rosenberg
  0 siblings, 1 reply; 4+ messages in thread
From: Jonas Fonseca @ 2009-08-22  3:32 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: Shawn O. Pearce, git

[With correct CC list. Sorry for the resend Robin]

On Thu, Aug 20, 2009 at 18:35, Robin
Rosenberg<robin.rosenberg.lists@dewire.com> wrote:
> onsdag 19 augusti 2009 15:18:11 skrev Jonas Fonseca <fonseca@diku.dk>:
>> Fixes breakage in the RepositoryCacheTest when running tests using:
>>
>>       mvn -f ./jgit-maven/jgit/pom.xml test
>> [...]
>> @@ -217,7 +217,7 @@ public void setUp() throws Exception {
>>               trash = new File(trashParent,"trash"+System.currentTimeMillis()+"."+(testcount++));
>> -             trash_git = new File(trash, ".git");
>> +             trash_git = new File(trash, ".git").getCanonicalFile();
>> @@ -307,7 +307,7 @@ protected Repository createNewEmptyRepo() throws IOException {
>>       protected Repository createNewEmptyRepo(boolean bare) throws IOException {
>>               final File newTestRepo = new File(trashParent, "new"
>>                               + System.currentTimeMillis() + "." + (testcount++)
>> -                             + (bare ? "" : "/") + ".git");
>> +                             + (bare ? "" : "/") + ".git").getCanonicalFile();
>
> We use getCanonicalFile here and Repository.gitDir  is initialized with getAbsoluteDir.

BTW, a simpler fix would be to initialize trashParent to a canonical
path, which might be less intrusive.

> Does this work on all platforms?

I have only tested on Linux.

> Seems linux normalized things when you do things like, but I'm not sure that happens everywhere.

If you think it is a problem, let's drop the patch. It just seemed
like a simple way to increase robustness.

--
Jonas Fonseca

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH JGIT] Ensure created test repositories use canonical paths
  2009-08-22  3:32   ` Jonas Fonseca
@ 2009-08-22 10:15     ` Robin Rosenberg
  0 siblings, 0 replies; 4+ messages in thread
From: Robin Rosenberg @ 2009-08-22 10:15 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: Shawn O. Pearce, git

lördag 22 augusti 2009 05:32:59 skrev Jonas Fonseca <fonseca@diku.dk>:
> [With correct CC list. Sorry for the resend Robin]
> 
> On Thu, Aug 20, 2009 at 18:35, Robin
> Rosenberg<robin.rosenberg.lists@dewire.com> wrote:
> > onsdag 19 augusti 2009 15:18:11 skrev Jonas Fonseca <fonseca@diku.dk>:
> >> Fixes breakage in the RepositoryCacheTest when running tests using:
> >>
> >>       mvn -f ./jgit-maven/jgit/pom.xml test
> >> [...]
> >> @@ -217,7 +217,7 @@ public void setUp() throws Exception {
> >>               trash = new File(trashParent,"trash"+System.currentTimeMillis()+"."+(testcount++));
> >> -             trash_git = new File(trash, ".git");
> >> +             trash_git = new File(trash, ".git").getCanonicalFile();
> >> @@ -307,7 +307,7 @@ protected Repository createNewEmptyRepo() throws IOException {
> >>       protected Repository createNewEmptyRepo(boolean bare) throws IOException {
> >>               final File newTestRepo = new File(trashParent, "new"
> >>                               + System.currentTimeMillis() + "." + (testcount++)
> >> -                             + (bare ? "" : "/") + ".git");
> >> +                             + (bare ? "" : "/") + ".git").getCanonicalFile();
> >
> > We use getCanonicalFile here and Repository.gitDir  is initialized with getAbsoluteDir.
> 
> BTW, a simpler fix would be to initialize trashParent to a canonical
> path, which might be less intrusive.
> 
> > Does this work on all platforms?
> 
> I have only tested on Linux.
> 
> > Seems linux normalized things when you do things like, but I'm not sure that happens everywhere.
> 
> If you think it is a problem, let's drop the patch. It just seemed
> like a simple way to increase robustness.

Just a hunch, can't prove it so I'll accept the patch.

-- robin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-22 10:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-19 13:18 [PATCH JGIT] Ensure created test repositories use canonical paths Jonas Fonseca
2009-08-20 22:35 ` Robin Rosenberg
2009-08-22  3:32   ` Jonas Fonseca
2009-08-22 10:15     ` Robin Rosenberg

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).