Re: [PATCH 2/2] update-hook-example: optionally allow non-fast-forward

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dmitry Potapov <dpotapov@xxxxxxxxx> 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@xxxxxxxxx>

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


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux