Glen Choo <chooglen@xxxxxxxxxx> writes: > + /* > + * NEEDSWORK: Submodules set/unset a value for > + * core.worktree when they are populated/unpopulated by > + * "git checkout" (and similar commands, see > + * submodule_move_head() and > + * connect_work_tree_and_git_dir()), but if the > + * submodule is unpopulated in another way (e.g. "git > + * rm", "rm -r"), core.worktree will still be set even > + * though the directory doesn't exist, and the child > + * process will crash while trying to chdir into the > + * nonexistent directory. > + * > + * In this case, we know that the submodule has no > + * working tree, so we can work around this by > + * setting "--work-tree=." (--bare does not work because > + * worktree settings take precedence over bare-ness). > + * However, this is not necessarily true in other cases, > + * so a generalized solution is still necessary. > + * > + * Possible solutions: > + * - teach "git [add|rm]" to unset core.worktree and > + * discourage users from removing submodules without > + * using a Git command. > + * - teach submodule child processes to ignore stale > + * core.worktree values. > + */ > + strvec_push(&task->git_args, "--work-tree=."); > + return task; Thanks - this is a good comment. I've also written other comments on this patch that are easier to describe in the context of an earlier conversation, so I've written these as replies to an earlier email: https://lore.kernel.org/git/20220304234622.647776-1-jonathantanmy@xxxxxxxxxx/ https://lore.kernel.org/git/20220304235328.649768-1-jonathantanmy@xxxxxxxxxx/