git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* why does builtin/init-db.c mention "/etc/core-git/templates/hooks/update"?
@ 2018-05-28 13:27 Robert P. J. Day
  2018-05-28 13:59 ` Sitaram Chamarty
  0 siblings, 1 reply; 3+ messages in thread
From: Robert P. J. Day @ 2018-05-28 13:27 UTC (permalink / raw)
  To: Git Mailing list


  just noticed this in builtin/init-db.c:

... snip ...
#ifndef DEFAULT_GIT_TEMPLATE_DIR
#define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
#endif
... snip ...
static void copy_templates_1(struct strbuf *path, struct strbuf *template_path,
                             DIR *dir)
{
        size_t path_baselen = path->len;
        size_t template_baselen = template_path->len;
        struct dirent *de;

        /* Note: if ".git/hooks" file exists in the repository being
         * re-initialized, /etc/core-git/templates/hooks/update would
         * cause "git init" to fail here.  I think this is sane but
         * it means that the set of templates we ship by default, along
         * with the way the namespace under .git/ is organized, should
         * be really carefully chosen.
         */
... snip ...

  should the reference to /etc/core-git/templates/hooks/update instead
refer to the directory /usr/share/git-core/templates/..., given the
default directory defined just a few lines above it? (there is no such
directory, /etc/core-git/, on my system.)

  more to the point, is that actually what the "update" hook does? i
just looked at the shipped sample, "update.sample", and it seems to be
related to tags:

  #!/bin/sh
  #
  # An example hook script to block unannotated tags from entering.
  # Called by "git receive-pack" with arguments: refname sha1-old sha1-new
  #
  # To enable this hook, rename this file to "update".

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

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

* Re: why does builtin/init-db.c mention "/etc/core-git/templates/hooks/update"?
  2018-05-28 13:27 why does builtin/init-db.c mention "/etc/core-git/templates/hooks/update"? Robert P. J. Day
@ 2018-05-28 13:59 ` Sitaram Chamarty
  2018-05-28 14:09   ` Robert P. J. Day
  0 siblings, 1 reply; 3+ messages in thread
From: Sitaram Chamarty @ 2018-05-28 13:59 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: Git Mailing list

On Mon, May 28, 2018 at 09:27:18AM -0400, Robert P. J. Day wrote:

[snipped the rest because I really don't know]

>   more to the point, is that actually what the "update" hook does? i
> just looked at the shipped sample, "update.sample", and it seems to be
> related to tags:
> 
>   #!/bin/sh
>   #
>   # An example hook script to block unannotated tags from entering.

no that's just a sample.  An update hook can do pretty much
anything, and if it exits with 0 status code, the actual update
succeeds.  If it exists with any non-zero exit code, the update
will fail.

This is (usually) the basis for a lot of checks that people may
want, from commit message format to access control at the ref
(branch/tag) level for write operations.

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

* Re: why does builtin/init-db.c mention "/etc/core-git/templates/hooks/update"?
  2018-05-28 13:59 ` Sitaram Chamarty
@ 2018-05-28 14:09   ` Robert P. J. Day
  0 siblings, 0 replies; 3+ messages in thread
From: Robert P. J. Day @ 2018-05-28 14:09 UTC (permalink / raw)
  To: Sitaram Chamarty; +Cc: Git Mailing list

On Mon, 28 May 2018, Sitaram Chamarty wrote:

> On Mon, May 28, 2018 at 09:27:18AM -0400, Robert P. J. Day wrote:
>
> [snipped the rest because I really don't know]
>
> >   more to the point, is that actually what the "update" hook does? i
> > just looked at the shipped sample, "update.sample", and it seems to be
> > related to tags:
> >
> >   #!/bin/sh
> >   #
> >   # An example hook script to block unannotated tags from entering.
>
> no that's just a sample.  An update hook can do pretty much
> anything, and if it exits with 0 status code, the actual update
> succeeds.  If it exists with any non-zero exit code, the update will
> fail.
>
> This is (usually) the basis for a lot of checks that people may
> want, from commit message format to access control at the ref
> (branch/tag) level for write operations.

  i'm not convinced that that reference is "just a sample." the
comment in builtin/init-db.c reads:

  /* Note: if ".git/hooks" file exists in the repository being
   * re-initialized, /etc/core-git/templates/hooks/update would
   * cause "git init" to fail here...

the reference to "/etc/core-git/templates/hooks/update" might lead
some people to believe that that somehow refers to the "update.sample"
hook that comes with a new repo, but that hook is specifically related
to git-receive-pack, and has nothing to do with re-initalizing a repo,
AFAICT.

  i'm just suggesting that that comment in buildin/init-db.c seems
more than a little inaccurate.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

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

end of thread, other threads:[~2018-05-28 14:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-28 13:27 why does builtin/init-db.c mention "/etc/core-git/templates/hooks/update"? Robert P. J. Day
2018-05-28 13:59 ` Sitaram Chamarty
2018-05-28 14:09   ` Robert P. J. Day

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).