From: Junio C Hamano <gitster@pobox.com>
To: Garbageyard <varuag.chhabra@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Git tag: pre-receive hook issue
Date: Fri, 17 Jul 2015 12:30:21 -0700 [thread overview]
Message-ID: <xmqqoaja1t0y.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1437159533304-7635764.post@n2.nabble.com> (Garbageyard's message of "Fri, 17 Jul 2015 11:58:53 -0700 (MST)")
Garbageyard <varuag.chhabra@gmail.com> writes:
> We have a pre-receive hook that checks for JIRA ID whenever someone pushes
> code to Git server. I'm trying to avoid this check when someone is applying
> a tag. Here's the link for the script: http://pastebin.com/VnMQp5ar
>
> This is the link for output: http://pastebin.com/tBGmYaZF
>
> Problem is that if i run the following command, the output that i get on
> command line is 0
>
> git describe --exact-match ac28ca721e67adc04078786164939989a5112d98 2>&1 |
> grep -o fatal | wc -w
I am not sure what you are trying to do in the first place.
: gitster x; git init garbage
Initialized empty Git repository in /var/tmp/x/garbage/.git/
: gitster x; cd garbage
: gitster garbage/master; git commit --allow-empty -m initial
[master (root-commit) b18cac2] initial
: gitster garbage/master; git tag v0.0 ;# lightweight
: gitster garbage/master; git commit --allow-empty -m second
[master d1de78e] second
: gitster garbage/master; git tag -a 'v0.1' v0.1
fatal: Failed to resolve 'v0.1' as a valid ref.
: gitster garbage/master; git tag -a -m 'v0.1' v0.1
: gitster garbage/master; git commit --allow-empty -m third
[master d1f1360] third
: gitster garbage/master; git describe --exact-match HEAD ;# third
fatal: no tag exactly matches 'd1f1360b46dfde8c6f341e48ce45d761ed37e357'
: gitster garbage/master; git describe --exact-match HEAD^ ;# second
v0.1
: gitster garbage/master; git describe --exact-match HEAD^^ ;# first
fatal: no tag exactly matches 'b18cac237055d9518f9f92bb4c0a4dac825dce17'
: gitster garbage/master; exit
I am feeding three _commits_, not tags. But one of them (i.e. the
one that happens to have an annotated tag) yields the "exact match"
tagname, as designed and expected.
But is it really what you want to do to skip such a commit? Why?
I also see a questionable thing in the earlier part of your script:
while read old_sha1 new_sha1 refname ; do
echo "stdin: [$old_sha1] [$new_sha1] [$refname]"
if [ "$old_sha1" == "0000000000000000000000000000000000000000" ] ; then
commits=$new_sha1
else
commits=`git rev-list $old_sha1..$new_sha1`
fi
for commit in $commits
do
...
When somebody pushes to an existing branch, you list all the new
commits that came in (i.e. 'git rev-list' is bounded by $old_sha1 at
the bottom). But when somebody pushes to a new branch, you only
include the tip to the list.
And you check everything on that list. Why? If I push three-commit
series to a new branch, wouldn't you want to validate all three of
them, just like you validate my push of a three-commit enhancement
to an existing branch?
while read old new name
do
case "$name" in refs/heads/tags/*) continue ;; esac
if test "$old" = 0000000000000000000000000000000000000000
then
git rev-list $old
else
git rev-list $old..$new
fi
done |
while read commit
do
Do a check on $commit
done
or something instead?
next prev parent reply other threads:[~2015-07-17 19:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-17 18:58 Git tag: pre-receive hook issue Garbageyard
2015-07-17 19:30 ` Junio C Hamano [this message]
2015-07-18 4:00 ` Jacob Keller
2015-07-18 20:08 ` Gaurav Chhabra
2015-07-18 21:19 ` Junio C Hamano
2015-07-18 22:22 ` Jacob Keller
2015-07-19 7:55 ` Gaurav Chhabra
2015-07-19 8:38 ` Jacob Keller
2015-07-19 10:13 ` Gaurav Chhabra
2015-07-19 23:35 ` Jacob Keller
2015-07-20 7:43 ` Gaurav Chhabra
2015-07-20 16:02 ` Keller, Jacob E
2015-07-22 19:46 ` Jakub Narębski
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqoaja1t0y.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=varuag.chhabra@gmail.com \
/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.
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).