From: "Benjamin R. Haskell" <zsh@benizi.com>
To: Frank Terbeck <ft@bewatermyfriend.org>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] _git: Also complete FETCH_HEAD, ORIG_HEAD and MERGE_HEAD.
Date: Mon, 3 May 2010 10:51:58 -0400 (EDT) [thread overview]
Message-ID: <alpine.LNX.2.01.1005031032000.5029@hp.internal> (raw)
In-Reply-To: <87d3xewu7y.fsf@ft.bewatermyfriend.org>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 2525 bytes --]
On Sun, 2 May 2010, Frank Terbeck wrote:
> Simon Ruderich wrote:
> > On Sat, May 01, 2010 at 02:17:19PM +0200, Frank Terbeck wrote:
> >>> I would prefer mine because of the speed penalty of Benjamin's
> >>> patch. Checking if the file exists in .git would be another
> >>> possibility.
> >>
> >> And that would be the one from workers-27813¹?
> >>
> >> Regards, Frank
> >>
> >> ¹ <http://www.zsh.org/mla/workers/2010/msg00265.html>
> >
> > Ah sorry. Yes, that's the one.
>
> Committed this one. Actually checking whether the head symbols are
> available at any time probably requires something like this:
>
> gdir="$(git rev-parse --git-dir)"
> [[ -f ${gdir}/ORIG_HEAD ]] && ...
> [[ -f ${gdir}/FETCH_HEAD ]] && ...
> ...
>
> I don't know if it's worth the additional fork.
That's essentially what my 'compromise' patch does. The one from
workers-27817 [links below].
==== this portion: ====
+ symbolic_heads=()
+ gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
+ __git_command_successful && symbolic_heads=( $gitdir/{,{ORIG,FETCH,MERGE}_}HEAD(N:t) )
=======================
As stated before, I think the fork is worth it. The three options were:
[27813]. always-complete: usually-incorrect, 0 extra forks
[27817]. --git-dir + filesystem tests: possibly-incorrect, 1 extra fork
[27814]. rev-parse each name: always correct, 4 extra forks
Personally, I think the 4 extra forks are worth it (The particular
execution path that this alters already does two _call_program git
forks). But, I'm not stuck on a system where forking is expensive (100
git forks takes ~1sec)[2], so I see the need for the compromise [27817].
[27813] is usually incorrect (depending on your workflow) because
FETCH_HEAD, ORIG_HEAD, and MERGE_HEAD come and go depending on what
actions you take on your repository.
The reason [27817] is possibly-incorrect is that the .git/*HEAD files
can exist even if the branch hasn't been born. (e.g. try 'git rev-parse
HEAD' in a newly-init'ed repo, even though .git/HEAD exists)
But, it's rare enough that the correctness vs. speed tradeoff seems
reasonable.
--
Best,
Ben
[27813] http://www.zsh.org/mla/workers/2010/msg00265.html
[27814] http://www.zsh.org/mla/workers/2010/msg00266.html
[27817] http://www.zsh.org/mla/workers/2010/msg00269.html
[2]
$ date ; r=( HEAD ORIG_HEAD --git-dir ) ; for l in {1..100} ; git rev-parse $r[$(( 1 + $RANDOM % $#r ))] 2>/dev/null >/dev/null ; date
Mon May 3 10:50:06 EDT 2010
Mon May 3 10:50:07 EDT 2010
next prev parent reply other threads:[~2010-05-03 15:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-21 17:23 Simon Ruderich
2010-03-21 19:48 ` Benjamin R. Haskell
2010-03-21 20:17 ` Nikolai Weibull
2010-03-22 1:25 ` Simon Ruderich
2010-03-22 2:30 ` Benjamin R. Haskell
2010-03-22 9:27 ` Nikolai Weibull
2010-03-29 0:07 ` Simon Ruderich
2010-05-01 8:28 ` Simon Ruderich
2010-05-01 10:46 ` Frank Terbeck
2010-05-01 12:12 ` Simon Ruderich
2010-05-01 12:17 ` Frank Terbeck
2010-05-01 20:32 ` Simon Ruderich
2010-05-02 9:04 ` Frank Terbeck
2010-05-03 14:51 ` Benjamin R. Haskell [this message]
2010-03-29 13:56 ` Benjamin R. Haskell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.01.1005031032000.5029@hp.internal \
--to=zsh@benizi.com \
--cc=ft@bewatermyfriend.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).