git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Correct documentation of 'reflog show' to explain it shows HEAD
@ 2007-08-19  8:18 Shawn O. Pearce
  2007-08-20 22:53 ` Issues with envelopesender and empty log messages using contrib/hooks/post-receive-email Matthew Gwynne
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn O. Pearce @ 2007-08-19  8:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

By default 'git reflog show' will show the reflog of 'HEAD' and not
the reflog of the current branch.  This is most likely due to the
work done a while ago as part of the detached HEAD series to allow
HEAD to have its own reflog independent of each branch's reflog.

Since 'git reflog show' is really just an obscure alias for 'git
log -g --abbrev-commit --pretty=oneline' it should behave the same
way and its documentation should match.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 Documentation/git-reflog.txt |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt
index 89bc9c5..29b7d9f 100644
--- a/Documentation/git-reflog.txt
+++ b/Documentation/git-reflog.txt
@@ -32,7 +32,8 @@ directly by the end users -- instead, see gitlink:git-gc[1].
 
 The subcommand "show" (which is also the default, in the absense of any
 subcommands) will take all the normal log options, and show the log of
-the current branch. It is basically an alias for 'git log -g --abbrev-commit
+`HEAD`, which will cover all recent actions, including branch switches.
+It is basically an alias for 'git log -g --abbrev-commit
 --pretty=oneline', see gitlink:git-log[1].
 
 
-- 
1.5.3.rc5.19.g0734d

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

* Issues with envelopesender and empty log messages using contrib/hooks/post-receive-email
  2007-08-19  8:18 [PATCH] Correct documentation of 'reflog show' to explain it shows HEAD Shawn O. Pearce
@ 2007-08-20 22:53 ` Matthew Gwynne
  2007-08-20 23:42   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Gwynne @ 2007-08-20 22:53 UTC (permalink / raw)
  To: git

I've recently encountered 2 problems with use of the example
post-receive-mail script in contrib/hooks/post-receive-email.

Firstly I found that having set hooks.envelopesender, the script ended
up sending mail with the envelope sender set to the email address
given literally surrounded by single quotes which caused the mail
server to complain about invalid address syntax.

The offending lines appears to be - 

if [ -n "$envelopesender" ]; then
   envelopesender="-f '$envelopesender'"
fi

which when replaced with 

if [ -n "$envelopesender" ]; then
   envelopesender="-f \"$envelopesender\""
fi

have the desired effect of the script using the unaltered envelope
sender when sending mail as set in hooks.envelopesender. I have
attached a diff to this effect.

The second problem is that when using a branch that is derived from
master, has some differences, but regularly has master merged into it
to keep it up to date. If one makes some changes to master, merges
these into the other branch, then pushes these to the repository with
the mail hook, the email regarding the changes to master has an empty
log message.

The relevant lines seem to be in generate_update_branch_email(), line
380 - 

git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
git rev-list --pretty --stdin $oldrev..$newrev

I understand git-rev-parse will return the negation of the heads of
boths branches (master and the other branch) and then the master
branch negation is grep outed. However that leaves essentially the
command - 

git rev-list --pretty --stdin $oldrev..$newrev ^$otherbranchhead

which when $oldrev and $newrev are in the other branch as well seems
to result in an empty list / no result as nothing before
$otherbranchhead should be shown, and $oldrev and $newrev are both
before $otherbranchhead in the stated case but have never been shown
in any mails.

Steps to reproduce :

1) Create a repository (repo1) with just the master branch and make
some commits.  
2) Copy contrib/hooks/post-receive-email to [.git/]hooks/post-receive
and chmod +x it.  
3) Create a branch (testbranch) in repo1 
4) Clone repo1 creating repo2 
5) Checkout repo1/testbranch in repo2 
6) Make some commits to testbranch in repo2 
7) Push from repo2 to repo1 
8) Make some commits in repo2/master 
9) Merge repo2/master into repo2/testbranch 
10) Push repo2 to repo1 
11) Notice an empty log message for the mail detailing changes to
master.

If I have misunderstood some key concepts rather than there being bugs
here, I apologise in advance, and would just like to know what stupid
thing I've done :) 

Matthew Gwynne

diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index c589a39..a733d0c 100644
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -608,7 +608,7 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
 	PAGER= generate_email $2 $3 $1
 else
 	if [ -n "$envelopesender" ]; then
-		envelopesender="-f '$envelopesender'"
+		envelopesender="-f \"$envelopesender\""
 	fi
 
 	while read oldrev newrev refname

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

* Re: Issues with envelopesender and empty log messages using contrib/hooks/post-receive-email
  2007-08-20 22:53 ` Issues with envelopesender and empty log messages using contrib/hooks/post-receive-email Matthew Gwynne
@ 2007-08-20 23:42   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2007-08-20 23:42 UTC (permalink / raw)
  To: Matthew Gwynne; +Cc: git, Andy Parkins

Matthew Gwynne <mathew.gwynne@gmail.com> writes:

> I've recently encountered 2 problems with use of the example
> post-receive-mail script in contrib/hooks/post-receive-email.

The script's author Andy Parkins Cc'ed.

> Firstly I found that having set hooks.envelopesender, the script ended
> up sending mail with the envelope sender set to the email address
> given literally surrounded by single quotes which caused the mail
> server to complain about invalid address syntax.
> ...
> diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
> index c589a39..a733d0c 100644
> --- a/contrib/hooks/post-receive-email
> +++ b/contrib/hooks/post-receive-email
> @@ -608,7 +608,7 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
>  	PAGER= generate_email $2 $3 $1
>  else
>  	if [ -n "$envelopesender" ]; then
> -		envelopesender="-f '$envelopesender'"
> +		envelopesender="-f \"$envelopesender\""
>  	fi
>  
>  	while read oldrev newrev refname

I do not think this is a correct fix either.

Suppose you have envelope sender "A B <c@d.xz>" and have
original or your version to massage that string.

A few lines below the part you quoted does this:

	/usr/sbin/sendmail -t $envelopesender

which would expand and split at $IFS into

	/usr/sbin/sendmail -t -f 'A    B      <c@d.xz>'
        $0                 $1 $2 $3    $4     $5 

which is wrong, but then your fixed version would read as:

	/usr/sbin/sendmail -t -f '"A   B      <c@d.xz>"'
        $0                 $1 $2 $3    $4     $5 

which looks just as wrong.

Perhaps you would need something like this (untested) patch.

---

 contrib/hooks/post-receive-email |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index c589a39..f1efd5f 100644
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -607,13 +607,10 @@ if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
 	# resend an email; they could redirect the output to sendmail themselves
 	PAGER= generate_email $2 $3 $1
 else
-	if [ -n "$envelopesender" ]; then
-		envelopesender="-f '$envelopesender'"
-	fi
-
 	while read oldrev newrev refname
 	do
 		generate_email $oldrev $newrev $refname |
-		/usr/sbin/sendmail -t $envelopesender
+		/usr/sbin/sendmail -t ${envelopesender:+"-f"} \
+			${envelopesender:+"$envelopesender"}
 	done
 fi

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

end of thread, other threads:[~2007-08-20 23:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-19  8:18 [PATCH] Correct documentation of 'reflog show' to explain it shows HEAD Shawn O. Pearce
2007-08-20 22:53 ` Issues with envelopesender and empty log messages using contrib/hooks/post-receive-email Matthew Gwynne
2007-08-20 23:42   ` Junio C Hamano

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 NNTP newsgroup(s).