From: Ben Knoble Date: Thu, 28 May 2026 14:28:51 GMT Subject: Re: git mv after the fact Message-ID: <1FEDBC47-5DDB-4C42-A7C7-695630D330BF@gmail.com> In-Reply-To: <877bootp3l.fsf@gitster.g> > Le 27 mai 2026 à 19:24, Junio C Hamano a écrit : > > Chris Torek writes: > >>> Chris Torek writes: >>>> A flag for "git mv" would be convenient (and slightly moreefficient ... >>> >> >> On Tue, May 26, 2026 at 8:09 PM Junio C Hamano wrote: >>> May be convenient, but I do not get the "efficient" part. >> >> A normal `git mv` renames the index entry and the file in the working >> tree without running `git add` on the *contents*, so there's no new hash >> computation. Presumably a `git mv --after foo bar` would do the same: verify >> that there is no existing `bar` in the index, that there is an existing `foo` in >> the index, and that there is no `foo` but there is a `bar` in the working tree, >> and then it would rename (add-and-remove, really, because of sorting) >> the index entry, without scanning the working tree contents. >> >> In other words, we skip reading the 3 terabyte file, or whatever. > > Yup, that matches what I wrote. We do not rehash and we only write > the index just once. One thing I wondered: if we don’t have an exact move but assume (by not hashing), doesn’t that mean the index would differ from what’s on disk? I originally thought that might be a problem, but the more I thought the more I realized that’s a fairly typical state anyway. Just seemed like a potential footgun to me, but perhaps not worth worrying about.