Re: [PATCH 10/15] update submodules: add submodule_move_head
- From
Ramsay Jones <ramsay@ramsayjones.plus.com>
- Date
- Feb 24, 2017, 01:21 UTC
- Message-ID
- <7e920dd5-3638-57d9-0ca1-3f8aed4d700b@ramsayjones.plus.com>
- In-Reply-To
- <20170223225735.10994-11-sbeller@google.com>
On 23/02/17 22:57, Stefan Beller wrote:
Show 45 quoted lines
> 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@google.com>
> ---
> 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.]
ATB, Ramsay Jones