Re: EXDEV when re-init with --separate-git-dir option
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 24, 2024, 15:39 UTC
- Message-ID
- <xmqq1q3iztmi.fsf@gitster.g>
- In-Reply-To
- <CAKOkDnMGRfQoNygYLiAxPZB2q=VMYvw8kyu1dM=pM843-FH41Q@mail.gmail.com>
"Jin, Di" <di_jin@brown.edu> writes:
> We discovered that re-init with option --separate-git-dir will throw > an EXDEV when the target directory is not on the same file system as > the original directory.
Yup, it is hitting the limitation of your filesystem. The code wants to move the original .git directory together with its contents to a new place, and it makes a single rename() system call to do so. When the system cannot do so, you'd get the error message you are seeing ("fatal: unable to move X to Y").
The code path could probably borrow some code to recursively "copy" directory from the local "git clone" code path, and then invent a new code to recursively remove the original ".git", and trigger that new code when rename() fails.
But at that point, only as a fall-back measure, it might be simpler and much less error prone to spawn a "mv src dst" as a subprocess using the run_command() API.
It would make a good bite-sized #leftoverbits project for aspiring new Git contributors. Any takers? ;-)
Thanks.