Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337101 - Need an alternative way to set user home
Summary: Need an alternative way to set user home
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 0.12-M1   Edit
Assignee: Shawn Pearce CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-14 06:32 EST by Thomas Hallgren CLA
Modified: 2011-03-15 11:24 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Hallgren CLA 2011-02-14 06:32:28 EST
I'm building a web service where I use JGit. Many users share the same JVM and the system property "user.home" can not be used to identify the directory where user data is stored. At present, I use a fairly ugly workaround where I do:

  Field f_userHome = FS.class.getDeclaredField("userHome");
  f_userHome.setAccessible(true);
  f_userHome.set(FS.DETECTED, wantedUserHome);

It would be nice to have a more supported way to accomplish this. Ideally, it should be possible to set this per jgit instance instead of globally.
Comment 1 Shawn Pearce CLA 2011-03-14 11:48:59 EDT
(In reply to comment #0)
> It would be nice to have a more supported way to accomplish this. Ideally, it
> should be possible to set this per jgit instance instead of globally.

What do you mean by "per jgit instance"? Per-repository? I guess that would be per-FS instance, and you need to configure the RepositoryBuilder with your custom FS that knows what userHome is.
Comment 2 Thomas Hallgren CLA 2011-03-14 12:03:27 EDT
I'm don't know what the best implementation would be. My basic problem is that I cannot rely on system properties since all users share the same VM. I think that's a very common case for any web service so it would be a really great feature to have an alternative solution given that JGit it's ideal for the job (pure Java in servlet container).
Comment 3 Shawn Pearce CLA 2011-03-14 12:21:10 EDT
I think this 4 part series resolves this request:

  http://egit.eclipse.org/r/2709
  http://egit.eclipse.org/r/2710
  http://egit.eclipse.org/r/2711
  http://egit.eclipse.org/r/2712

Especially the last two, because you can now do:

  static final FS mine = FS.DETECTED.newInstance().setUserHome(...);

  Repository db = new FileRepositoryBuilder().setFS(mine)....build();
Comment 4 Chris Aniszczyk CLA 2011-03-15 11:24:30 EDT
These changes are now merged in. Thanks Shawn.