Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new repositories as --shared #559

Closed
gitblit opened this issue Aug 12, 2015 · 8 comments
Closed

Create new repositories as --shared #559

gitblit opened this issue Aug 12, 2015 · 8 comments

Comments

@gitblit
Copy link
Collaborator

gitblit commented Aug 12, 2015

Originally reported on Google Code with ID 263

When creating a new repository or forking a repository, the repo is created as --bare,
but not as --shared.

Personally I think all server hosted repos should be created with --shared, i.e. g+s
permissions under Unix. But it would be nice if we could at least have an option to
set when creating a new repository if it should be created as if created with git init
--bare --shared.

This would make it easier to use Gitblit in an environment where repository access
is not exclusively through Gitblit but Gitblit is rather used as an add-on to manage
repositories.

Reported by f.zschocke on 2013-07-02 15:32:44

@gitblit
Copy link
Collaborator Author

gitblit commented Aug 12, 2015

Unfortunately, as far as I can see JGit does not (yet) support --shared.

Reported by James.Moger on 2013-07-02 15:57:27

@gitblit
Copy link
Collaborator Author

gitblit commented Aug 12, 2015

So, do you think you could work around that by directly setting the config variable
"core.sharedRepository" and maybe even "receive.denyNonFastForwards" with JGit Config
methods?

Reported by f.zschocke on 2013-07-03 12:52:17

@gitblit
Copy link
Collaborator Author

gitblit commented Aug 12, 2015

Yes, I can manipulate the repo config and I can use JNA to workaround Java 6 limitations
in setting unix filesystem permissions to emulate what you describe, but I'm not comfortable
making this change for the next release which should be out in a day or two.

If you need this now then I recommend creating the repos from outside Gitblit and clearing
Gitblit's cache afterwards so that it sees your new repo(s).

You want --shared because you are cloning/pushing these repos with file:// urls, right?

BTW, while I can set "receive.denyNonFastForwards" for other Git tooling, Gitblit does
not respect this setting.

Reported by James.Moger on 2013-07-03 13:32:17

@gitblit
Copy link
Collaborator Author

gitblit commented Aug 12, 2015

No, I want shared because I use Gitblit for creating/forking repositories but not as
the exclusive access control tool. Access is also through Apache and via SSH. So all
repositories are owned by the git group and g+s. 

Reported by f.zschocke on 2013-07-03 13:45:57

@gitblit
Copy link
Collaborator Author

gitblit commented Aug 12, 2015

James, could you give me some pointers to the code I should be looking at in order to
"manipulate the repo config" and "use JNA to workaround Java 6 limitations in setting
unix filesystem permissions"? I would like to start working on this as it is my next
most pressing issue for our installation.

Reported by f.zschocke on 2013-08-12 18:12:31

@gitblit
Copy link
Collaborator Author

gitblit commented Aug 12, 2015

JNA is already a dependency so this should be less painful.

Below is half of what you want - setting the sharedRepository flag - and a hint on
how to do the remainder.  The linked CLibrary api may not be the correct one.  The
basic plan is to set the repo config and file system permissions after the repository
is init'd, since JGit doesn't support --shared.

JGitUtils.createRepository() {
  try {
    Git git = Git.init().setDirectory(new File(repositoriesFolder, name)).setBare(true).call();
    boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows")
> -1;
    if (!isWindows) {
      StoredConfig config = git.getRepository().getConfig();
      config.setBoolean("core", null, "sharedRepository", true);
      config.save();

      // JNA here
      // http://stackoverflow.com/a/664453/830200
    }
    return git.getRepository();
  } catch (IOException e) {
    throw new RuntimeException(e);
  } catch (GitAPIException e) {
    throw new RuntimeException(e);
  }
}


Reported by James.Moger on 2013-08-12 18:44:15

@gitblit
Copy link
Collaborator Author

gitblit commented Aug 12, 2015

Merged to master

Reported by James.Moger on 2013-09-17 21:57:21

  • Status changed: Queued
  • Labels added: Milestone-1.4.0

@gitblit
Copy link
Collaborator Author

gitblit commented Aug 12, 2015

1.4.0 released.

Reported by James.Moger on 2014-03-09 18:06:21

  • Status changed: Done

@gitblit gitblit closed this as completed Aug 12, 2015
@flaix flaix modified the milestone: 1.4.0 Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants