From: Jakub Narebski <jnareb@gmail.com>
To: "Pat Notz" <pknotz@sandia.gov>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Fix contrib/hooks/post-receive-email for new branch with no new commits
Date: Tue, 10 Feb 2009 07:46:31 -0800 (PST) [thread overview]
Message-ID: <m3ab8uuwfg.fsf@localhost.localdomain> (raw)
In-Reply-To: <1234273695-4981-1-git-send-email-pknotz@sandia.gov>
"Pat Notz" <pknotz@sandia.gov> writes:
> In the show_new_revisions function, the original code:
>
> git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
>
> isn't quite right since one can create a new branch and push it without
> any new commits. In that case, two refs will have the same sha1 but
> both would get filtered by the 'grep'. In the end, we'll show ALL the
> history which is not what we want. Instead, we should list the branches
> by name and remove the branch being updated and THEN pass that list
> through rev-parse.
Good idea, bad execution.
>
> Signed-off-by: Pat Notz <pknotz@sandia.gov>
> ---
> contrib/hooks/post-receive-email | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
> index 28a3c0e..116f89c 100644
> --- a/contrib/hooks/post-receive-email
> +++ b/contrib/hooks/post-receive-email
> @@ -615,7 +615,9 @@ show_new_revisions()
> revspec=$oldrev..$newrev
> fi
>
> - git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
> + this_branch=$(echo $refname | sed 's@refs/heads/@@')
> + other_branches=$(git branch | sed 's/\*//g' | grep -v $this_branch)
git-branch is porcelain, git-branch is porcelain, git-branch is porcelain,
git-branch is porcelain, git-branch is porcelain, git-branch is porcelain,
git-branch is porcelain, git-branch is porcelain, ...
Don't use sed if shell will suffice...
Either:
+ this_branch=$refname
+ other_branches=$(git for-each-ref --format='%(refname)' refs/heads/ |
+ grep -v $this_branch)
or
+ this_branch=${refname#refs/heads/}
...
> + git rev-parse --not $other_branches |
> if [ -z "$custom_showrev" ]
> then
> git rev-list --pretty --stdin $revspec
> --
> 1.6.1.2
>
>
--
Jakub Narebski
Poland
ShadeHawk on #git
next prev parent reply other threads:[~2009-02-10 15:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-10 13:48 [PATCH] Fix contrib/hooks/post-receive-email for new branch with no new commits Pat Notz
2009-02-10 15:46 ` Jakub Narebski [this message]
2009-02-10 15:59 ` Johannes Schindelin
2009-02-10 16:30 ` Junio C Hamano
2009-02-10 16:43 ` [PATCH] Fix contrib/hooks/post-receive-email for new duplicate branch Pat Notz
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=m3ab8uuwfg.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=pknotz@sandia.gov \
/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 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).