On Thu, Feb 23, 2017 at 5:21 PM, Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx> wrote: > > > On 23/02/17 22:57, Stefan Beller wrote: >> In later patches we introduce the options and flag for commands >> that modify the working directory, e.g. git-checkout. >> >> This piece of code will be used universally for >> all these working tree modifications as it >> * supports dry run to answer the question: >> "Is it safe to change the submodule to this new state?" >> e.g. is it overwriting untracked files or are there local >> changes that would be overwritten? >> * supports a force flag that can be used for resetting >> the tree. >> >> Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx> >> --- >> submodule.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> submodule.h | 7 ++++ >> 2 files changed, 142 insertions(+) >> >> diff --git a/submodule.c b/submodule.c >> index 0b2596e88a..a2cf8c9376 100644 >> --- a/submodule.c >> +++ b/submodule.c >> @@ -1239,6 +1239,141 @@ int bad_to_remove_submodule(const char *path, unsigned flags) >> return ret; >> } >> >> +static int submodule_has_dirty_index(const struct submodule *sub) >> +{ >> + struct child_process cp = CHILD_PROCESS_INIT; >> + >> + prepare_submodule_repo_env_no_git_dir(&cp.env_array); >> + >> + cp.git_cmd = 1; >> + argv_array_pushl(&cp.args, "diff-index", "--quiet", \ >> + "--cached", "HEAD", NULL); >> + cp.no_stdin = 1; >> + cp.no_stdout = 1; >> + cp.dir = sub->path; >> + if (start_command(&cp)) >> + die("could not recurse into submodule '%s'", sub->path); >> + >> + return finish_command(&cp); >> +} >> + >> +void submodule_reset_index(const char *path) > > I was just about to send a patch against the previous series > (in pu branch last night), but since you have sent another > version ... > > In the last series this was called 'submodule_clean_index()' > and, since it is a file-local symbol, should be marked with > static. I haven't applied these patches to check, but the > interdiff in the cover letter leads me to believe that this > will also apply to the renamed function. > > [The patch subject was also slightly different.] > good catch. Yes submodule_reset_index ought to be static. fixed in a reroll.