git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: diff-index --cached on bare repository

From
Jeff King <peff@peff.net>
Date
Jan 30, 2009, 20:06 UTC
Message-ID
<20090130200625.GB3054@coredump.intra.peff.net>
In-Reply-To
<glv901$c5v$1@ger.gmane.org>
On Fri, Jan 30, 2009 at 04:13:53PM +0000, Johannes Gilger wrote:
Show 7 quoted lines
> today I stumbled over the output of "git diff-index --cached HEAD" in a 
> bare repository. While diff-index HEAD just reminds me that I got to 
> have a work-tree, --cached outputs all the files in HEAD as deleted. The 
> question is if this is intended behaviour? Or is it irrelevant because 
> diff-index is only plumbing? I found a mail of the gitk-team working 
> around this, which is funny because I discovered this while working on 
> GitX.

Generally commands which don't make sense in a bare repository are forbidden. But diff-index _can_ work in a bare repository, since there is no reason you can't do index-only operations. However, a bare repo has no index by default, in which case diff-index shows the results you saw.

So no, it's not a bug, but it is potentially confusing. I think nobody ever worried about it because diff-index is plumbing, so users are unlikely to stumble into it.

-Peff
Previous: Johannes Gilger
Message 2 of 2 in “diff-index --cached on bare repository”
  1. Johannes GilgerJan 30, 2009
  2. Jeff KingJan 30, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.