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

Re: BUG in git diff-index

From
ALAndy Lowry <andy.work@nglowry.com>
Date
Mar 31, 2016, 19:30 UTC
Message-ID
<56FD7AE8.4090905@nglowry.com>
In-Reply-To
<20160331142704.GC31116@sigill.intra.peff.net>
OK, great. I think the update-index command is what I need.

If you'll indulge me, I'll describe my use-case in detail, and if you see anything screwy about it, I'd appreciate feedback. But don't feel obligated - you've been a great help already.

This is all about publishing updates to a static web site hosted as a gh-pages branch on a github repo.

Our master branch has everything that goes into building the site, and we use subtree push to update gh-pages with the embedded subtree that contains the generated site.

I'm creating a bash script that does the publishing, and as a general rule, we want to publish only from the master branch, and only if it's clean and up-to-date. And we also want to make sure that the embedded site reflects the current source content.

It's in that last requirement where diff-index comes in. The script runs a site build, and then should fail the policy check if that results in any changes to the working tree (including the embedded site)/. /I don't want the script to change the index in any way (e.g. so that unintended changes revealed by this policy check are less likely to be accidentally commited).

If I understand correctly, the update-index operation you indicated will not change index membership at all, but will simply resync the index members with actual working tree files.

So I think now that the script should do "update-index --refresh" followed by "diff-index --quiet HEAD". Sound correct?

Andy
On 3/31/2016 10:27 AM, Jeff King wrote:
Show 19 quoted lines
> On Thu, Mar 31, 2016 at 10:12:07AM -0400, Andy Lowry wrote:
>
>> What I'm actually after is a tree-to-filesystem comparison, regardless
>> of index. I've currently got a "diff" thrown in as a "work-around"
>> before "diff-index", but  now I understand it's not a workaround at
>> all. If there's a better way to achieve what I'm after, I'd appreciate
>> a tip. Otherwise I'll just change the comments explaining why there's
>> a "diff" in my script.
> If your workaround is just to refresh the index, then you can do "git
> update-index --refresh", rather than diff.
>
> I don't think there is a plumbing command to do a direct
> filesystem-to-tree comparison without having an index at all. "git diff
> <treeish>" claims in the documentation to do so, but besides not being
> plumbing, I think it is really just doing the same thing as diff-index,
> under the hood. The index is a pretty fundamental part of git's view of
> the working tree.
>
> -Peff
Previous: Jeff KingNext: Junio C Hamano
Message 6 of 13 in “BUG in git diff-index”
  1. Andy LowryMar 31, 2016
  2. Carlos Martín NietoMar 31, 2016
  3. Jeff KingMar 31, 2016
  4. Andy LowryMar 31, 2016
  5. Jeff KingMar 31, 2016
  6. Andy LowryMar 31, 2016
  7. Junio C HamanoMar 31, 2016
  8. Marc HerbertSep 26, 2017
  9. Eric WongSep 26, 2017
  10. Google indexing https://public-inbox.org/git (was: BUG in git diff-index)Marc Herbert, Sep 26, 2017
  11. Wrong -dirty suffix set by setlocalversion (was: BUG in git diff-index)Marc Herbert, Sep 27, 2017
  12. Mike MasonMay 24, 2018
  13. Marc HerbertMay 25, 2018

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.