Torsten Bögershausen <tboegi@xxxxxx> writes: > On Tue, Aug 08, 2023 at 10:36:54AM -0700, Junio C Hamano wrote: >> "Sebastian Thiel via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: >> >> > From: Sebastian Thiel <sebastian.thiel@xxxxxxxxxx> >> > > > The patch makes sense to me, Junio's comments included. > >> Shouldn't it do something similar to >> >> $ mv D1 D2 > > Couldn't resist to test it ;-) > > The result would be > renamed: D1/file1 -> D2/D1/file1 Sure. The lstat() in question is about the case where a different D2/D1 already exists, either as a file (which will definitely break as we do not and should not do unlink-and-then-mkdir) or as a directory (which may be OK in some cases to get a union of the contents in the original D1 and D2/D1, but in general not a good idea). And in the latter case, i.e. when D2/D1 exists as a directory, we should not say "cannot move directory over file". So, the check that does not care what the dest_dir's type is fine. but the error message is wrong. "cannot move directory over file, source=D1, destination=D1/D2" is the message we would get in such a case. We probably just should say "destination already exists, source=D1, destination=D1/D2" or something like that.