Incorrect work dir for submodule fetch operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
Since Git 2.21 the Windows version have frequently reported
  error: cannot spawn git: Invalid argument

and still do in 2.34 and 2.35.

The reported error does not seem to have any bad effects, but the error report is an irritation.

At the time, this was reported to the Git for Windows team as <https://github.com/git-for-windows/git/issues/2126>

As it has not yet been fixed, the past couple of days I have investigated more closely.

The error is printed for a submodule.c function submodule_has_commits() which starts the command "rev-parse" for a submodule.

The reason for the error is that the function starts the command for submodule "foo", which is present in the checkout directory. However, the actual CWD dir is the git dir for the current module, not the checkout directory, and the change directory operation therefore fails.

The "rev-parse" made it possible for me to connect this problem with a different problem that I have been seeing at Linux and Mac, where the error message
  fatal: exec 'rev-list': cd to 'foo' failed: No such file or directory

is frequently reported, especially when a branch in the parent module has new submodules defined.

AFAICT, the reason for the CWD being the git dir, not the checkout dir, is that get_next_submodule() in submodule.c starts a fetch operation directly in the git dir, instead of the checkout directory

Further, submodule_has_commits() which is called by the fetch command via fetch_populated_submodules() assumes that its CWD is in the checkout directory.


After a bisect it seems the regression point for this was commit be76c2128234d94b47f7087152ee55d08bb65d88 <https://github.com/git-for-windows/git/commit/be76c2128234d94b47f7087152ee55d08bb65d88>, which added the fetch in git dir command in get_next_submodule().

A testcase for reproducing the issue can be found in <https://github.com/git-for-windows/git/issues/2126#issuecomment-1064153093> (assumes default branch is "main"), which builds up a submodule set based on two Chromium repos (chromium src, and depot_tools)

I am uncertain what the proper fix for this issue should be, but my guess is that each command need to specify whether it is going to work relative to the git dir, or the checkout dir. It is IMO conceivable that other commands may have this kind of problem, especially in a submodule context, or that future features may encounter them.



--
Sincerely,
Yngve N. Pettersen
Vivaldi Technologies AS



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux