Re: [PATCH] contrib/hooks/post-receive-email: get description from repo.git/config

2013-05-06 Thread Trond Hasle Amundsen
Matthieu Moy  writes:

>>> The included patch attempts to improve post-receive-email. It's a
>>
>> Please don't ;-)
>
> More precisely: you should have a look at git-multimail (in directory
> contrib/, in branch for now pu/, or from
> https://github.com/mhagger/git-multimail) before spending time on
> post-receive-email.

Thanks for the tip, I'll check it out. I used post-receive-email out of
convenience, as it was already there.

Regards,
-- 
Trond H. Amundsen 
Center for Information Technology Services, University of Oslo
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] contrib/hooks/post-receive-email: get description from repo.git/config

2013-05-06 Thread Trond Hasle Amundsen
Junio C Hamano  writes:

> 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.

Allright, noted.

>> From 878a7af9088e2bcc3afc9b09b9023f1f188c844b Mon Sep 17 00:00:00 2001
>> From: Trond Hasle Amundsen 
>> 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.

So many rules.. ;) Also noted.

>> +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.

That doesn't work, you'll always call "git config" unless the string
matches "Unnamed repository". If you negate the expr line it still
doesn't work. To avoid calling "git config" I'd rather suggest something
like this:

  projectdesc=$(sed -ne 1p "$GIT_DIR/description" 2>/dev/null)
  if [ -z "$projectdesc" ]; then
  projectdesc=$(git config gitweb.description)
  fi

And let this block remain intact:

  if expr "$projectdesc" : "Unnamed repository.*$" >/dev/null
  then
  projectdesc="UNNAMED PROJECT"
  fi

The only change would then be the three added lines containing the if
block that calls "git config" if the "projectdesc" variable is
empty. The idea is just to get the description from config if the
description file doesn't exist.

Just curious.. why would we avoid calling "git config" unless necessary?

Regards,
-- 
Trond H. Amundsen 
Center for Information Technology Services, University of Oslo
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] contrib/hooks/post-receive-email: get description from repo.git/config

2013-05-06 Thread Trond Hasle Amundsen
Trond Hasle Amundsen  writes:

> The included patch attempts to improve post-receive-email. It's a
> 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.

Bah.. It seems I attached this as MIME, sorry about that. Here it is,
properly inlined this time:

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

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 
---
 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
-- 
1.7.1


Cheers,
-- 
Trond H. Amundsen 
Center for Information Technology Services, University of Oslo
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] contrib/hooks/post-receive-email: get description from repo.git/config

2013-05-06 Thread Trond Hasle Amundsen

Hello,

The included patch attempts to improve post-receive-email. It's a
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 
Date: Mon, 6 May 2013 15:41:25 +0200
Subject: [PATCH] contrib/hooks/post-receive-email: get description from repo.git/config

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 
---
 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
-- 
1.7.1


Cheers,
-- 
Trond H. Amundsen 
Center for Information Technology Services, University of Oslo