Re: [PATCH] git-completion.bash: always swallow error output of for-each-ref
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 4, 2016, 19:06 UTC
- Message-ID
- <xmqqwpqki9bh.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <alpine.DEB.2.20.1602041216240.2964@virtualbox>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 20 quoted lines
>> $ time git for-each-ref --format='%(refname:short)' refs/tags >/dev/null >> >> real 0m0.009s >> user 0m0.004s >> sys 0m0.004s > > And the timings in the ticket I mentioned above are not pretty small: > 0.055s vs 1.341s > >> The upcoming refname:strip does much better: >> >> $ time git for-each-ref --format='%(refname:strip=2)' refs/tags >/dev/null >> >> real 0m0.004s >> user 0m0.000s >> sys 0m0.004s > > This is funny: after reading the commit message at > https://github.com/git/git/commit/0571979b it eludes me why strip=2 should > be so much faster than short...
"short" tries to ensure that the result is not ambiguous within the repository, so when asked to shorten refs/heads/foo, it needs to check if refs/tags/foo exists. "strip=2" textually strips two levels from the top without worrying about ambiguity across different hierarchies.