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

Re: [RFC PATCH] completion: support excluding refs

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 24, 2016, 16:52 UTC
Message-ID
<xmqqy43mqfcp.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160824084152.2857-1-judge.packham@gmail.com>
Chris Packham <judge.packham@gmail.com> writes:
Show 15 quoted lines
> Allow completion of refs with a ^ prefix. This allows completion of
> commands like 'git log HEAD ^origin/master'.
> ...
> +			[[ "$cur" == ^* ]] && pfx="^"
>  			for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
> -				if [ -e "$dir/$i" ]; then echo $i; fi
> +				if [ -e "$dir/$i" ]; then echo $pfx$i; fi
>  			done
>  			format="refname:short"
>  			refs="refs/tags refs/heads refs/remotes"
>  			;;
>  		esac
> -		git --git-dir="$dir" for-each-ref --format="%($format)" \
> +		git --git-dir="$dir" for-each-ref --format="$pfx%($format)" \
>  			$refs

That looks like a reasonable approach to me (but I am no expert in this area myself).

Previous: Chris Packham
Message 2 of 2 in “completion: support excluding refs”
  1. completion: support excluding refsChris Packham, Aug 24, 2016
  2. Junio C HamanoAug 24, 2016

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.