{"thread":{"id":"48586","subject":"why does builtin/init-db.c mention \"/etc/core-git/templates/hooks/update\"?","startedAt":"2018-05-28T13:29:19Z","lastAt":"2018-05-28T14:12:15Z","messageCount":3,"participants":["Robert P. J. Day","Sitaram Chamarty"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"348668","messageId":"alpine.LFD.2.21.1805280920100.12022@localhost.localdomain","threadId":"48586","inReplyTo":null,"subject":"why does builtin/init-db.c mention \"/etc/core-git/templates/hooks/update\"?","fromName":"Robert P. J. Day","fromEmail":"rpjday@crashcourse.ca","sentAt":"2018-05-28T13:27:18Z","receivedAt":"2018-05-28T13:29:19Z","isPatch":false,"sender":{"key":"rpjday@crashcourse.ca","avatar":"https://avatars.githubusercontent.com/u/226084077?v=4"},"body":"\n  just noticed this in builtin/init-db.c:\n\n... snip ...\n#ifndef DEFAULT_GIT_TEMPLATE_DIR\n#define DEFAULT_GIT_TEMPLATE_DIR \"/usr/share/git-core/templates\"\n#endif\n... snip ...\nstatic void copy_templates_1(struct strbuf *path, struct strbuf *template_path,\n                             DIR *dir)\n{\n        size_t path_baselen = path->len;\n        size_t template_baselen = template_path->len;\n        struct dirent *de;\n\n        /* Note: if \".git/hooks\" file exists in the repository being\n         * re-initialized, /etc/core-git/templates/hooks/update would\n         * cause \"git init\" to fail here.  I think this is sane but\n         * it means that the set of templates we ship by default, along\n         * with the way the namespace under .git/ is organized, should\n         * be really carefully chosen.\n         */\n... snip ...\n\n  should the reference to /etc/core-git/templates/hooks/update instead\nrefer to the directory /usr/share/git-core/templates/..., given the\ndefault directory defined just a few lines above it? (there is no such\ndirectory, /etc/core-git/, on my system.)\n\n  more to the point, is that actually what the \"update\" hook does? i\njust looked at the shipped sample, \"update.sample\", and it seems to be\nrelated to tags:\n\n  #!/bin/sh\n  #\n  # An example hook script to block unannotated tags from entering.\n  # Called by \"git receive-pack\" with arguments: refname sha1-old sha1-new\n  #\n  # To enable this hook, rename this file to \"update\".\n\nrday\n\n-- \n\n========================================================================\nRobert P. J. Day                                 Ottawa, Ontario, CANADA\n                  http://crashcourse.ca/dokuwiki\n\nTwitter:                                       http://twitter.com/rpjday\nLinkedIn:                               http://ca.linkedin.com/in/rpjday\n========================================================================\n"},{"id":"348670","messageId":"20180528135902.GA362@sita-lt.atc.tcs.com","threadId":"48586","inReplyTo":"alpine.LFD.2.21.1805280920100.12022@localhost.localdomain","subject":"Re: why does builtin/init-db.c mention \"/etc/core-git/templates/hooks/update\"?","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2018-05-28T13:59:02Z","receivedAt":"2018-05-28T13:59:14Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"On Mon, May 28, 2018 at 09:27:18AM -0400, Robert P. J. Day wrote:\n\n[snipped the rest because I really don't know]\n\n>   more to the point, is that actually what the \"update\" hook does? i\n> just looked at the shipped sample, \"update.sample\", and it seems to be\n> related to tags:\n> \n>   #!/bin/sh\n>   #\n>   # An example hook script to block unannotated tags from entering.\n\nno that's just a sample.  An update hook can do pretty much\nanything, and if it exits with 0 status code, the actual update\nsucceeds.  If it exists with any non-zero exit code, the update\nwill fail.\n\nThis is (usually) the basis for a lot of checks that people may\nwant, from commit message format to access control at the ref\n(branch/tag) level for write operations.\n"},{"id":"348672","messageId":"alpine.LFD.2.21.1805281006250.13672@localhost.localdomain","threadId":"48586","inReplyTo":"20180528135902.GA362@sita-lt.atc.tcs.com","subject":"Re: why does builtin/init-db.c mention \"/etc/core-git/templates/hooks/update\"?","fromName":"Robert P. J. Day","fromEmail":"rpjday@crashcourse.ca","sentAt":"2018-05-28T14:09:12Z","receivedAt":"2018-05-28T14:12:15Z","isPatch":false,"sender":{"key":"rpjday@crashcourse.ca","avatar":"https://avatars.githubusercontent.com/u/226084077?v=4"},"body":"On Mon, 28 May 2018, Sitaram Chamarty wrote:\n\n> On Mon, May 28, 2018 at 09:27:18AM -0400, Robert P. J. Day wrote:\n>\n> [snipped the rest because I really don't know]\n>\n> >   more to the point, is that actually what the \"update\" hook does? i\n> > just looked at the shipped sample, \"update.sample\", and it seems to be\n> > related to tags:\n> >\n> >   #!/bin/sh\n> >   #\n> >   # An example hook script to block unannotated tags from entering.\n>\n> no that's just a sample.  An update hook can do pretty much\n> anything, and if it exits with 0 status code, the actual update\n> succeeds.  If it exists with any non-zero exit code, the update will\n> fail.\n>\n> This is (usually) the basis for a lot of checks that people may\n> want, from commit message format to access control at the ref\n> (branch/tag) level for write operations.\n\n  i'm not convinced that that reference is \"just a sample.\" the\ncomment in builtin/init-db.c reads:\n\n  /* Note: if \".git/hooks\" file exists in the repository being\n   * re-initialized, /etc/core-git/templates/hooks/update would\n   * cause \"git init\" to fail here...\n\nthe reference to \"/etc/core-git/templates/hooks/update\" might lead\nsome people to believe that that somehow refers to the \"update.sample\"\nhook that comes with a new repo, but that hook is specifically related\nto git-receive-pack, and has nothing to do with re-initalizing a repo,\nAFAICT.\n\n  i'm just suggesting that that comment in buildin/init-db.c seems\nmore than a little inaccurate.\n\nrday\n\n-- \n\n========================================================================\nRobert P. J. Day                                 Ottawa, Ontario, CANADA\n                  http://crashcourse.ca/dokuwiki\n\nTwitter:                                       http://twitter.com/rpjday\nLinkedIn:                               http://ca.linkedin.com/in/rpjday\n========================================================================\n"}]}