{"thread":{"id":"18540","subject":"Question: Is it possible to host a writable git repo over both http and ssh?","startedAt":"2009-03-25T17:29:59Z","lastAt":"2009-03-26T16:57:32Z","messageCount":9,"participants":["Mike Gaffney","Jeff King","Robin Rosenberg","Rogan Dawes","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"109380","messageId":"49CA6A17.6050903@gmail.com","threadId":"18540","inReplyTo":null,"subject":"Question: Is it possible to host a writable git repo over both http and ssh?","fromName":"Mike Gaffney","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-03-25T17:29:59Z","receivedAt":"2009-03-25T17:29:59Z","isPatch":false,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"I am trying to setup a git repo internally at my work. I would like to \nmake the repo accessable via https for both read and write so that we \nmay access it from customer locations which don't allow anything but \nhttps. I would also like to host it via SSH because that protocol is \nmuch faster. I know that when you push with http it runs 'git \nupdate-server-info', would I have to make the ssh pushes do the same? \nWill this even work?\n\nThanks, \n    Mike Gaffney\n"},{"id":"109458","messageId":"20090326021259.GA5835@coredump.intra.peff.net","threadId":"18540","inReplyTo":"49CA6A17.6050903@gmail.com","subject":"Re: Question: Is it possible to host a writable git repo over both http and ssh?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-03-26T02:12:59Z","receivedAt":"2009-03-26T02:12:59Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 25, 2009 at 12:29:59PM -0500, Mike Gaffney wrote:\n\n> I am trying to setup a git repo internally at my work. I would like to  \n> make the repo accessable via https for both read and write so that we may \n> access it from customer locations which don't allow anything but https. I \n> would also like to host it via SSH because that protocol is much faster. I \n> know that when you push with http it runs 'git update-server-info', would \n> I have to make the ssh pushes do the same? Will this even work?\n\nYes, it should work just fine. All pushes, no matter how they arrive at\nthe repository, will need to run \"git update-server-info\", which is what\nallows \"dumb\" protocols like http to read from the repository. The\ndefault post-update hook does this; you just need to enable it by \"cd\n.git/hooks && mv post-update.sample post-update\".\n\n-Peff\n"},{"id":"109465","messageId":"49CAF607.1020905@gmail.com","threadId":"18540","inReplyTo":"20090326021259.GA5835@coredump.intra.peff.net","subject":"Re: Question: Is it possible to host a writable git repo over both http and ssh?","fromName":"Mike Gaffney","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-03-26T03:27:03Z","receivedAt":"2009-03-26T03:27:03Z","isPatch":false,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"Does this go for JGit as well?\n\n-Mike\n\nJeff King wrote:\n> On Wed, Mar 25, 2009 at 12:29:59PM -0500, Mike Gaffney wrote:\n> \n>> I am trying to setup a git repo internally at my work. I would like to  \n>> make the repo accessable via https for both read and write so that we may \n>> access it from customer locations which don't allow anything but https. I \n>> would also like to host it via SSH because that protocol is much faster. I \n>> know that when you push with http it runs 'git update-server-info', would \n>> I have to make the ssh pushes do the same? Will this even work?\n> \n> Yes, it should work just fine. All pushes, no matter how they arrive at\n> the repository, will need to run \"git update-server-info\", which is what\n> allows \"dumb\" protocols like http to read from the repository. The\n> default post-update hook does this; you just need to enable it by \"cd\n> .git/hooks && mv post-update.sample post-update\".\n> \n> -Peff\n\n-- \n-Mike Gaffney (http://rdocul.us)\n"},{"id":"109468","messageId":"20090326033623.GA8031@coredump.intra.peff.net","threadId":"18540","inReplyTo":"49CAF607.1020905@gmail.com","subject":"Re: Question: Is it possible to host a writable git repo over both http and ssh?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-03-26T03:36:23Z","receivedAt":"2009-03-26T03:36:23Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 25, 2009 at 10:27:03PM -0500, Mike Gaffney wrote:\n\n> Does this go for JGit as well?\n\nThe hook must be enabled on the server side; are you running JGit on the\nserver, or regular git?\n\n-Peff\n"},{"id":"109476","messageId":"49CB0AC1.2070006@gmail.com","threadId":"18540","inReplyTo":"20090326033623.GA8031@coredump.intra.peff.net","subject":"Re: Question: Is it possible to host a writable git repo over both http and ssh?","fromName":"Mike Gaffney","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-03-26T04:55:29Z","receivedAt":"2009-03-26T04:55:29Z","isPatch":false,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"I'm actually trying to take what Sean did with gerrit and extract a full Java/MinaSSHD based server that doesn't require a real user account and is configurable by spring. So yes, I'm using JGit on the server.\n\n-Mike\n\nJeff King wrote:\n> On Wed, Mar 25, 2009 at 10:27:03PM -0500, Mike Gaffney wrote:\n> \n>> Does this go for JGit as well?\n> \n> The hook must be enabled on the server side; are you running JGit on the\n> server, or regular git?\n> \n> -Peff\n\n-- \n-Mike Gaffney (http://rdocul.us)\n"},{"id":"109486","messageId":"20090326045650.GA13628@coredump.intra.peff.net","threadId":"18540","inReplyTo":"49CB0AC1.2070006@gmail.com","subject":"Re: Question: Is it possible to host a writable git repo over both http and ssh?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-03-26T04:56:51Z","receivedAt":"2009-03-26T04:56:51Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 25, 2009 at 11:55:29PM -0500, Mike Gaffney wrote:\n\n> I'm actually trying to take what Sean did with gerrit and extract a\n> full Java/MinaSSHD based server that doesn't require a real user\n> account and is configurable by spring. So yes, I'm using JGit on the\n> server.\n\nAh. In that case, I don't know whether JGit respects all hooks. You\nshould ask Shawn (Shawn, we are talking about a post-update to run\nupdate-server-info). :)\n\n-Peff\n"},{"id":"109488","messageId":"200903260618.33019.robin.rosenberg.lists@dewire.com","threadId":"18540","inReplyTo":"20090326045650.GA13628@coredump.intra.peff.net","subject":"Re: Question: Is it possible to host a writable git repo over both http and ssh?","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-03-26T05:18:32Z","receivedAt":"2009-03-26T05:18:32Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"torsdag 26 mars 2009 05:56:51 skrev Jeff King <peff@peff.net>:\n> On Wed, Mar 25, 2009 at 11:55:29PM -0500, Mike Gaffney wrote:\n> \n> > I'm actually trying to take what Sean did with gerrit and extract a\n> > full Java/MinaSSHD based server that doesn't require a real user\n> > account and is configurable by spring. So yes, I'm using JGit on the\n> > server.\n> \n> Ah. In that case, I don't know whether JGit respects all hooks. You\n> should ask Shawn (Shawn, we are talking about a post-update to run\n> update-server-info). :)\n\nArguably it should. but it doesn't. Then there is a question as to what\nformat those hooks should be. Shell scripts would run into platform\nissues and jgit based stuff should have as little as possible of that, but\na similar mechanism should exist.\n\n-- robin\n"},{"id":"109513","messageId":"49CB4EF1.6050902@dawes.za.net","threadId":"18540","inReplyTo":"200903260618.33019.robin.rosenberg.lists@dewire.com","subject":"Re: Question: Is it possible to host a writable git repo over both http and ssh?","fromName":"Rogan Dawes","fromEmail":"lists@dawes.za.net","sentAt":"2009-03-26T09:46:25Z","receivedAt":"2009-03-26T09:46:25Z","isPatch":false,"sender":{"key":"lists@dawes.za.net","avatar":null},"body":"Robin Rosenberg wrote:\n> torsdag 26 mars 2009 05:56:51 skrev Jeff King <peff@peff.net>:\n>> On Wed, Mar 25, 2009 at 11:55:29PM -0500, Mike Gaffney wrote:\n>>\n>>> I'm actually trying to take what Sean did with gerrit and extract a\n>>> full Java/MinaSSHD based server that doesn't require a real user\n>>> account and is configurable by spring. So yes, I'm using JGit on the\n>>> server.\n>> Ah. In that case, I don't know whether JGit respects all hooks. You\n>> should ask Shawn (Shawn, we are talking about a post-update to run\n>> update-server-info). :)\n> \n> Arguably it should. but it doesn't. Then there is a question as to what\n> format those hooks should be. Shell scripts would run into platform\n> issues and jgit based stuff should have as little as possible of that, but\n> a similar mechanism should exist.\n> \n> -- robin\n> \n\nMaybe support executing scripts via Bean Scripting Framework?\n\nThat would allow scripts to be written in any of the supported\nlanguages, as long as the appropriate interpreter is present.\n\ne.g. BeanShell, Groovy, Jython, etc\n\nSee http://jakarta.apache.org/bsf/\n\nIf you define an interface for each hook, the scripts could implement\nthe interface, and execute that way.\n\nHere is an example, mishmashed from\n<http://www.beanshell.org/examples/actionhandler.html> and\n<http://jvm-languages.com/wiki/Bean_Scripting_Framework#Interacting_with_Complex_Objects>:\n\n======8x===== Java code =========\npublic class BSFFileUtils\n{\n   public Object evalFile (BSFManager manager, File file)\n       throws IOException\n   {\n      String fileName = file.getPath();\n\n      String language = manager.getLangFromFilename(fileName);\n      String code = extractFileContents(file);\n\n      return manager.eval(language, fileName, 0, 0, code);\n   }\n\n   private String extractFileContents (File file)\n      throws IOException\n   {\n      StringBuffer buf = new StringBuffer();\n\n      BufferedReader r = new BufferedReader(new FileReader(file));\n      try {\n         int len;\n         char[] chars = new char[8192];\n\n         while ((len = r.read(chars, 0, chars.length)) != -1) {\n           buf.append(chars, 0, len);\n         }\n\n         return buf.toString();\n      } finally {\n          r.close();\n      }\n   }\n}\n\npublic static void main (String[] args)\n{\n   String directory = args[0];\n   File file = new File(\"actionHandler.bsh\");\n\n   BSFManager manager = new BSFManager();\n\n   ActionListener listener = (ActionListener)\nBSFFileUtils.evalFile(manager, file);\n\n   JButton button = new JButton(\"MyButton\");\n   button.addActionListener(listener);\n\n   JFrame f = new JFrame();\n   f.getContentPane().add( button );\n   f.show();\n}\n\n======8x===== BeanShell code ========= actionHandler.bsh\n\nimport java.awt.event.ActionListener;\n\nactionPerformed( e ) {\n    print(\"Button Pressed: \" + e);\n}\n\nreturn (ActionListener)this;\n\n======8x==============================\n\nHaving said all this, it is probably worth implementing\nupdate-server-info in Java, so as to avoid having to shell out to\nperform this action, and keep it all platform-independent.\n\nRogan\n"},{"id":"109555","messageId":"20090326165732.GD23521@spearce.org","threadId":"18540","inReplyTo":"49CB4EF1.6050902@dawes.za.net","subject":"Re: Question: Is it possible to host a writable git repo over both http and ssh?","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-03-26T16:57:32Z","receivedAt":"2009-03-26T16:57:32Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Rogan Dawes <lists@dawes.za.net> wrote:\n> Robin Rosenberg wrote:\n> > torsdag 26 mars 2009 05:56:51 skrev Jeff King <peff@peff.net>:\n> >> On Wed, Mar 25, 2009 at 11:55:29PM -0500, Mike Gaffney wrote:\n> >>\n> >>> I'm actually trying to take what Sean did with gerrit and extract a\n> >>> full Java/MinaSSHD based server that doesn't require a real user\n> >>> account and is configurable by spring. So yes, I'm using JGit on the\n> >>> server.\n> >> Ah. In that case, I don't know whether JGit respects all hooks. You\n> >> should ask Shawn (Shawn, we are talking about a post-update to run\n> >> update-server-info). :)\n\nJGit already has the native code needed for update-server-info. \nLook at WalkPushConnection:\n\n  line 185-187 calls refWriter.writeInfoRefs() to update the\n  GIT_DIR/info/refs for dumb transports.  We just need to call\n  that in the end of the receive code.\n\n  line 236 calls WalkRemoteObjectDatabase.writeInfoPacks() to\n  update the GIT_DIR/objects/info/packs file.  This needs to\n  be abstracted out so we can more easily reuse it.\n\n> > Arguably it should. but it doesn't. Then there is a question as to what\n> > format those hooks should be. Shell scripts would run into platform\n> > issues and jgit based stuff should have as little as possible of that, but\n> > a similar mechanism should exist.\n\nYup, I agree.\n\nAt the very least we should suppot doing the update-server-info\nlogic from pure Java, as it is probably the most common operation\npeople would want in a post receive hook.\n\n> Maybe support executing scripts via Bean Scripting Framework?\n> \n> That would allow scripts to be written in any of the supported\n> languages, as long as the appropriate interpreter is present.\n> \n> e.g. BeanShell, Groovy, Jython, etc\n> \n> See http://jakarta.apache.org/bsf/\n> \n> If you define an interface for each hook, the scripts could implement\n> the interface, and execute that way.\n\nYes, that is one option.  I'd like to get a reasonable binding to\nBSF for JGit, but its more of a wish than a real need for me, so\nI just don't bother.  I think many people who want to script Git\nfrom Python would be reasonably happy with executing that script\nthrough Jython if there was a decent binding.\n \n-- \nShawn.\n"}]}