Frank Terbeck wrote on Mon, Jun 02, 2014 at 10:14:22 +0200: > 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. My concern was not with using diff-index but with using the empty tree. Since Aaron says using it would be robust, let's just use it. Attached. > 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). It's mentioned in this thread, good enough for me. Daniel