All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Trond Hasle Amundsen <t.h.amundsen@usit.uio.no>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] contrib/hooks/post-receive-email: get description from repo.git/config
Date: Mon, 06 May 2013 08:36:15 -0700	[thread overview]
Message-ID: <7vtxmgruhc.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <15tsj20cizd.fsf@tux.uio.no> (Trond Hasle Amundsen's message of "Mon, 06 May 2013 15:53:42 +0200")

Trond Hasle Amundsen <t.h.amundsen@usit.uio.no> writes:

> Hello,
>
> The included patch attempts to improve post-receive-email. It's a

Please don't ;-)

Eh, actually, thanks for the patch.

But when you send a patch the next time around, please have the
above and the next three lines (i.e. "introductory text") _below_
the three-dash line.

> trivial change, but one that helps us Gitolite users. Comments are
> welcome, and this is my first attempt at contributing to the Git
> project. Please keep me on CC as I'm not on the list.

>
> From 878a7af9088e2bcc3afc9b09b9023f1f188c844b Mon Sep 17 00:00:00 2001
> From: Trond Hasle Amundsen <t.h.amundsen@usit.uio.no>
> Date: Mon, 6 May 2013 15:41:25 +0200
> Subject: [PATCH] contrib/hooks/post-receive-email: get description from repo.git/config

And remove these five lines above.  We will read the authorship and
subject from the e-mail header of your message.

>
> When getting the project description, we first try gitweb.description
> entry in repo.git/config, but repo.git/description takes precedence if
> it exists. This behaviour mimics that of Gitweb, and is what we want
> when using Gitolite, which deletes repo.git/description upon repo
> creation and rather maintains a gitweb.description entry in
> repo.git/config if a description is configured.
>
> Signed-off-by: Trond Hasle Amundsen <t.h.amundsen@usit.uio.no>
> ---
>  contrib/hooks/post-receive-email |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
> index 0e5b72d..6ce046a 100755
> --- a/contrib/hooks/post-receive-email
> +++ b/contrib/hooks/post-receive-email
> @@ -714,7 +714,14 @@ if [ -z "$GIT_DIR" ]; then
>  	exit 1
>  fi
>  
> -projectdesc=$(sed -ne '1p' "$GIT_DIR/description" 2>/dev/null)
> +# Get the repo's description. First try gitweb.description entry in
> +# repo.git/config, but repo.git/description takes precedence if it
> +# exists. This behaviour mimics that of Gitweb.
> +projectdesc=$(git config gitweb.description)
> +if [ -f "$GIT_DIR/description" ]; then
> +        projectdesc=$(sed -ne '1p' "$GIT_DIR/description" 2>/dev/null)
> +fi
> +
>  # Check if the description is unchanged from it's default, and shorten it to
>  # a more manageable length if it is
>  if expr "$projectdesc" : "Unnamed repository.*$" >/dev/null

If description file takes precedence, then the right order to do
this would be

    projectdesc=$(sed -ne 1p "$GIT_DIR/description" 2>/dev/null)
    if expr "$projectdesc" : "Unnamed repository" >/dev/null
    then
            : use it as is
    elif projectdesc=$(git config gitweb.description)
    then
            : use it as is
    else
            projectdesc="UNNAMED PROJECT"
    fi

to avoid calling "git config" when it is not even necessary.

We can obviously shorten it by making it less readable, e.g.        

    projectdesc=$(sed -ne 1p "$GIT_DIR/description" 2>/dev/null)

    ! expr "$projectdesc" : "Unnamed repository" >/dev/null ||
    projectdesc=$(git config gitweb.description) ||
    projectdesc="UNNAMED PROJECT"

but I do not think we want to go in that direction ;-)

  parent reply	other threads:[~2013-05-06 15:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-06 13:53 [PATCH] contrib/hooks/post-receive-email: get description from repo.git/config Trond Hasle Amundsen
2013-05-06 15:22 ` Trond Hasle Amundsen
2013-05-06 15:36 ` Junio C Hamano [this message]
2013-05-06 15:42   ` Matthieu Moy
2013-05-06 16:29     ` Trond Hasle Amundsen
2013-05-07  6:36     ` Junio C Hamano
2013-05-07  7:46       ` Michael Haggerty
2013-05-07 15:15         ` Junio C Hamano
2013-05-07 15:36           ` Matthieu Moy
2013-07-01 21:58         ` Junio C Hamano
2013-07-02  9:12           ` Michael Haggerty
2013-07-02 18:51             ` Junio C Hamano
2013-05-07  7:49       ` Matthieu Moy
2013-05-07 14:51         ` Junio C Hamano
2013-05-06 16:26   ` Trond Hasle Amundsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vtxmgruhc.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=t.h.amundsen@usit.uio.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.