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

Re: [PATCH 3/3] git abbref-ref: new porcelain for abbreviate_ref()

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 22, 2008, 15:32 UTC
Message-ID
<20080922153222.GD3669@spearce.org>
In-Reply-To
<1222074591-26548-3-git-send-email-bert.wesarg@googlemail.com>
Bert Wesarg <bert.wesarg@googlemail.com> wrote:
Show 5 quoted lines
> This gives direct access to the abbreviate_ref() function. The operation
> mode defaults to the core.warnambiguousrefs value, like the refname:short
> format, but can be explicitly changed with the --{,no}-strict option.
> 
> The bash completion script utilizes this new command.
And it slows down too, doesn't it?  Now we are doing a fork per
branch during completion.  Yikes.  Didn't you just post a series
about making completion faster?
 
> Junio, if this is not a porcelain, tell me.
IMHO its plumbing.  Porcelain is used by a human.  Plumbing is the
bits needed to make human interfaces.
 
Show 56 quoted lines
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 93f0881..7f002c0 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -112,9 +112,9 @@ __git_ps1 ()
>  		fi
>  
>  		if [ -n "$1" ]; then
> -			printf "$1" "${b##refs/heads/}$r"
> +			printf "$1" "$(git abbrev-ref $b)$r"
>  		else
> -			printf " (%s)" "${b##refs/heads/}$r"
> +			printf " (%s)" "$(git abbrev-ref $b)$r"
>  		fi
>  	fi
>  }
> @@ -162,7 +162,7 @@ __git_heads ()
>  		case "$is_hash,$i" in
>  		y,*) is_hash=n ;;
>  		n,*^{}) is_hash=y ;;
> -		n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
> +		n,refs/heads/*) is_hash=y; echo "$(git abbrev-ref $i)" ;;
>  		n,*) is_hash=y; echo "$i" ;;
>  		esac
>  	done
> @@ -180,7 +180,7 @@ __git_tags ()
>  		case "$is_hash,$i" in
>  		y,*) is_hash=n ;;
>  		n,*^{}) is_hash=y ;;
> -		n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
> +		n,refs/tags/*) is_hash=y; echo "$(git abbrev-ref $i)" ;;
>  		n,*) is_hash=y; echo "$i" ;;
>  		esac
>  	done
> @@ -199,9 +199,9 @@ __git_refs ()
>  		case "$is_hash,$i" in
>  		y,*) is_hash=n ;;
>  		n,*^{}) is_hash=y ;;
> -		n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
> -		n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
> -		n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
> +		n,refs/tags/*) is_hash=y; echo "$(git abbrev-ref $i)" ;;
> +		n,refs/heads/*) is_hash=y; echo "$(git abbrev-ref $i)" ;;
> +		n,refs/remotes/*) is_hash=y; echo "$(git abbrev-ref $i)" ;;
>  		n,*) is_hash=y; echo "$i" ;;
>  		esac
>  	done
> @@ -222,7 +222,7 @@ __git_refs_remotes ()
>  		case "$is_hash,$i" in
>  		n,refs/heads/*)
>  			is_hash=y
> -			echo "$i:refs/remotes/$1/${i#refs/heads/}"
> +			echo "$i:refs/remotes/$1/$(git abbrev-ref $i)"
>  			;;
>  		y,*) is_hash=n ;;
>  		n,*^{}) is_hash=y ;;
-- 
Shawn.
Previous: Bert WesargNext: Junio C Hamano
Message 4 of 16 in “for-each-ref: utilize core.warnambiguousrefs for strict refname:short format”
  1. 1/3 for-each-ref: utilize core.warnambiguousrefs for strict refname:short formatBert Wesarg, Sep 22, 2008
  2. 2/3 for-each-ref: factor out get_short_ref() into refs.c:abbreviate_refname()Bert Wesarg, Sep 22, 2008
  3. 3/3 git abbref-ref: new porcelain for abbreviate_ref()Bert Wesarg, Sep 22, 2008
  4. Shawn O. PearceSep 22, 2008
  5. Junio C HamanoSep 22, 2008
  6. Bert WesargSep 22, 2008
  7. Bert WesargSep 22, 2008
  8. Junio C HamanoSep 22, 2008
  9. Bert WesargSep 22, 2008
  10. Junio C HamanoOct 17, 2008
  11. Shawn O. PearceOct 18, 2008
  12. Bert WesargOct 18, 2008
  13. get_short_ref(): add strict modeBert Wesarg, Apr 11, 2009
  14. Junio C HamanoApr 11, 2009
  15. Bert WesargApr 11, 2009
  16. for-each-ref: refname:short utilize core.warnAmbiguousRefsBert Wesarg, Apr 11, 2009

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.