From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13698 invoked by alias); 2 Jun 2014 08:15:22 -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: 32659 Received: (qmail 27808 invoked from network); 2 Jun 2014 08:15:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 From: Frank Terbeck To: zsh-workers@zsh.org Subject: Re: [PATCH] vcs_info git: Fix stagedstr for empty repos In-Reply-To: <20140601022653.GE1820@tarsus.local2> (Daniel Shahaf's message of "Sun, 1 Jun 2014 02:26:53 +0000") References: <20140601022653.GE1820@tarsus.local2> User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) Date: Mon, 02 Jun 2014 10:14:22 +0200 Message-ID: <87vbsj4tk1.fsf@ft.bewatermyfriend.org> MIME-Version: 1.0 Content-Type: text/plain X-Df-Sender: NDMwNDQ0 Hello Daniel, Daniel Shahaf wrote: > vcs_info git false-negatives to detect staged changes in a repository that has > no commits. Attached a patch for that. Great! > The patch includes two variants for computing the "has staged changes?" bit in > empty repositories: one via 'git ls-files' and one via git's empty tree. > > - The output of ls-files isn't O(1), but I tested with a 3000-file tree and > didn't notice a slowdown, so I suppose it's acceptable. > > - 'diff-index --cached --quiet $empty_tree' is an O(1) operation, but I am not > sure whether it is forwards compatible with future versions of Git, i.e., > whether it's a hack that happens to work or a legitimate use of git's API. > > WDYT? I'm with Aaron on this one. IIRC, git uses the diff-index command in various places, so I don't think it'll be removed anytime soon. Unless you got other insight (personally, I'm not following the development of any version control system very closely anymore), I suppose we don't need two variants of the same thing in the code. If you don't want the second variant to be forgotten, you can always put it into the change's commit message. But in the code I'd just use the variant that you think is faster (if only theoretically). Regards, Frank -- In protocol design, perfection has been reached not when there is nothing left to add, but when there is nothing left to take away. -- RFC 1925