Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use is_submodule_active() instead of spawning a process
Use is_submodule_active() instead of spawning a new process for every submodule in prepare_submodule_summary(). Quote from Dscho: > + /* Also show added or modified modules which are checked out */ > + cp_rev_parse.dir = p->sm_path; > + cp_rev_parse.git_cmd = 1; > + cp_rev_parse.no_stderr = 1; > + cp_rev_parse.no_stdout = 1; > + > + argv_array_pushl(&cp_rev_parse.args, "rev-parse", > + "--git-dir", NULL); > + > + if (!run_command(&cp_rev_parse)) I wonder whether we really need to waste an entire spawned process on figuring out whether `p->sm_path` refers to an active repository. Wouldn't `is_submodule_active(r, p->sm_path)` fulfill the same purpose? ----------------------------------------------------------- The shell version just tests for a gitdir. --------------8<----------- GIT_DIR="$sm_path/.git" git rev-parse --git-dir >/dev/null 2>&1 && printf '%s\n' "$sm_path" -------------->8----------- Then we should also do just that instead of spawning a CP ever. The 'rev-parse' Documentation states ========================= --git-dir Show $GIT_DIR if defined. Otherwise show the path to the .git directory. The path shown, when relative, is relative to the current working directory. If $GIT_DIR is not defined and the current directory is not detected to lie in a Git repository or work tree print a message to stderr and exit with nonzero status. ========================= Another way to do this is via the helper function 'is_nonbare_repository_dir()' (not using is_git_directory() because of the failure it was causing before) 823a287 Therefore, instead of spawning a CP ever, do a check with the aforementioned function. All tests pass. https://lore.kernel.org/git/nycvar.QRO.7.76.6.2007031712160.50@tvgsbejvaqbjf.bet/
- Loading branch information