git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 25, 2008, 20:04 UTC
Message-ID
<7vtzfhz3fb.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1214382416-6687-2-git-send-email-dpotapov@gmail.com>
Dmitry Potapov <dpotapov@gmail.com> writes:
Show 5 quoted lines
> 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>
Show 7 quoted lines
>    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.
Previous: Dmitry PotapovNext: Dmitry Potapov
Message 3 of 4 in “fix update-hook-example to work with packed tag references”
  1. 1/2 fix update-hook-example to work with packed tag referencesDmitry Potapov, Jun 25, 2008
  2. 2/2 update-hook-example: optionally allow non-fast-forwardDmitry Potapov, Jun 25, 2008
  3. Junio C HamanoJun 25, 2008
  4. update-hook-example: optionally allow non-fast-forwardDmitry Potapov, Jun 25, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.