From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15910 invoked by alias); 3 May 2010 15:01:17 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27945 Received: (qmail 26727 invoked from network); 3 May 2010 15:01:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Mon, 3 May 2010 10:51:58 -0400 (EDT) From: "Benjamin R. Haskell" To: Frank Terbeck cc: zsh-workers@zsh.org Subject: Re: [PATCH] _git: Also complete FETCH_HEAD, ORIG_HEAD and MERGE_HEAD. In-Reply-To: <87d3xewu7y.fsf@ft.bewatermyfriend.org> Message-ID: References: <20100322012544.GA6014@ruderich.org> <20100329000715.GA25919@ruderich.org> <20100501082845.GA5704@ruderich.org> <87tyqrx5lj.fsf@ft.bewatermyfriend.org> <20100501121201.GA15260@ruderich.org> <87ljc3x1dc.fsf@ft.bewatermyfriend.org> <20100501203213.GA27571@ruderich.org> <87d3xewu7y.fsf@ft.bewatermyfriend.org> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1463810530-1519482778-1272898318=:5029" ---1463810530-1519482778-1272898318=:5029 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: 8BIT 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 > >> > >> ¹ > > > > 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 ---1463810530-1519482778-1272898318=:5029--