From: Junio C Hamano <gitster@pobox.com>
To: Dmitry Potapov <dpotapov@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] update-hook-example: optionally allow non-fast-forward
Date: Wed, 25 Jun 2008 13:04:56 -0700 [thread overview]
Message-ID: <7vtzfhz3fb.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1214382416-6687-2-git-send-email-dpotapov@gmail.com> (Dmitry Potapov's message of "Wed, 25 Jun 2008 12:26:56 +0400")
Dmitry Potapov <dpotapov@gmail.com> writes:
> Sometimes it is desirable to have non-fast-forward branches in a
> shared repository. A typical example of that is the 'pu' branch.
> This patch extends the format of allowed-users and allow-groups
> files by using the '+' sign at the beginning as the mark that
> non-fast-forward pushes are permitted to the branch.
Thanks. 1/2 queued for 'maint' (as it was an obvious fix) to be included
in 1.5.6.1, but not this one that is a feature enhancement even though it
is in docs.
> Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
> rc=$(cat $allowed_users_file | grep -v '^#' | grep -v '^$' |
> while read head_pattern user_patterns; do
> - matchlen=$(expr "$1" : "$head_pattern")
> - if [ "$matchlen" == "${#1}" ]; then
> + matchlen=$(expr "$1" : "${head_pattern#+}")
> + allow_noff=$(expr substr "$head_pattern" 1 1)
> + if [ "$matchlen" = "${#1}" -a \( -z "$noff" -o "$allow_noff" = '+' \) ]; then
"expr substr"? Please don't.
cf. http://www.opengroup.org/onlinepubs/000095399/utilities/expr.html
I'd probably write this part like so:
... pipe ... |
while read heads users
do
# does this rule apply to us?
head_pattern=${heads#+}
matchlen=$(expr "$1" : "$head_pattern")
test "$matchlen" = ${#1} || continue
# if non-ff, $heads must be with the '+' prefix
test -n "$noff" &&
test "z$head_pattern" = "z$heads" && continue
... Ok this is good.
next prev parent reply other threads:[~2008-06-25 20:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-25 8:26 [PATCH 1/2] fix update-hook-example to work with packed tag references Dmitry Potapov
2008-06-25 8:26 ` [PATCH 2/2] update-hook-example: optionally allow non-fast-forward Dmitry Potapov
2008-06-25 20:04 ` Junio C Hamano [this message]
2008-06-25 23:14 ` [PATCH v2] " Dmitry Potapov
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=7vtzfhz3fb.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=dpotapov@gmail.com \
--cc=git@vger.kernel.org \
/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).