git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: Prathamesh Chavan <pc44800@gmail.com>
Cc: git <git@vger.kernel.org>, Stefan Beller <sbeller@google.com>
Subject: Re: [GSoC][PATCH 6/6 v2] submodule: port submodule subcommand 'deinit' from shell to C
Date: Tue, 27 Jun 2017 09:18:28 +0200	[thread overview]
Message-ID: <CAP8UFD1mdgtHWt0CD32O=jXPkGLBiba-41DUchT4WT7CheH4bA@mail.gmail.com> (raw)
In-Reply-To: <20170626231108.23640-6-pc44800@gmail.com>

On Tue, Jun 27, 2017 at 1:11 AM, Prathamesh Chavan <pc44800@gmail.com> wrote:

> +static void deinit_submodule(const struct cache_entry *list_item,
> +                            void *cb_data)
> +{
> +       struct deinit_cb *info = cb_data;
> +       const struct submodule *sub;
> +       char *displaypath = NULL;
> +       struct child_process cp_config = CHILD_PROCESS_INIT;
> +       struct strbuf sb_config = STRBUF_INIT;
> +       char *sm_path = xstrdup(list_item->name);
> +       char *sub_git_dir = xstrfmt("%s/.git", sm_path);
> +
> +       sub = submodule_from_path(null_sha1, sm_path);
> +
> +       if (!sub->name)

In the previous patch "!sub" is used before "!sub->url", so we might
want to check "!sub" here too.

> +               goto cleanup;
> +
> +       displaypath = get_submodule_displaypath(sm_path, info->prefix);
> +
> +       /* remove the submodule work tree (unless the user already did it) */
> +       if (is_directory(sm_path)) {
> +               struct child_process cp = CHILD_PROCESS_INIT;
> +
> +               /* protect submodules containing a .git directory */
> +               if (is_git_directory(sub_git_dir))
> +                       die(_("Submodule work tree '%s' contains a .git "
> +                             "directory use 'rm -rf' if you really want "
> +                             "to remove it including all of its history"),
> +                             displaypath);
> +
> +               if (!info->force) {
> +                       struct child_process cp_rm = CHILD_PROCESS_INIT;
> +                       cp_rm.git_cmd = 1;
> +                       argv_array_pushl(&cp_rm.args, "rm", "-qn", sm_path,
> +                                        NULL);
> +
> +                       /* list_item->name is changed by cmd_rm() below */

It looks like cmd_rm() is not used anymore below, so this comment
could go and the sm_path variable might not be needed any more.

> +                       if (run_command(&cp_rm))
> +                               die(_("Submodule work tree '%s' contains local "
> +                                     "modifications; use '-f' to discard them"),
> +                                     displaypath);
> +               }
> +
> +               cp.use_shell = 1;

Do we really need a shell here?

> +               argv_array_pushl(&cp.args, "rm", "-rf", sm_path, NULL);
> +               if (!run_command(&cp)) {
> +                       if (!info->quiet)
> +                               printf(_("Cleared directory '%s'\n"),
> +                                        displaypath);
> +               } else {
> +                       if (!info->quiet)
> +                               printf(_("Could not remove submodule work tree '%s'\n"),
> +                                        displaypath);
> +               }
> +       }
> +
> +       if (mkdir(sm_path, 0700))

Are you sure about the 0700 mode?
Shouldn't this depend on the shared repository settings?

> +               die(_("could not create empty submodule directory %s"),
> +                     displaypath);

  reply	other threads:[~2017-06-27  7:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26 23:09 [GSoC] Update: Week 6 Prathamesh Chavan
2017-06-26 23:11 ` [GSoC][PATCH 1/6 v2] submodule--helper: introduce for_each_submodule_list Prathamesh Chavan
2017-06-26 23:11   ` [GSoC][PATCH 2/6 v2] submodule: port subcommand foreach from shell to C Prathamesh Chavan
2017-06-27  6:06     ` Christian Couder
2017-06-26 23:11   ` [GSoC][PATCH 3/6 v2] submodule: port set_name_rev " Prathamesh Chavan
2017-06-26 23:11   ` [GSoC][PATCH 4/6 v2] submodule: port submodule subcommand status Prathamesh Chavan
2017-06-26 23:11   ` [GSoC][PATCH 5/6 v2] submodule: port submodule subcommand sync from shell to C Prathamesh Chavan
2017-06-27  6:37     ` Christian Couder
2017-06-26 23:11   ` [GSoC][PATCH 6/6 v2] submodule: port submodule subcommand 'deinit' " Prathamesh Chavan
2017-06-27  7:18     ` Christian Couder [this message]
2017-06-28 19:53   ` [GSoC][PATCH 1/6 v2] submodule--helper: introduce for_each_submodule_list Junio C Hamano
2017-06-29 11:47     ` Prathamesh Chavan
2017-06-30 19:47 ` [GSoC][PATCH 1/5 v3] submodule--helper: introduce get_submodule_displaypath() Prathamesh Chavan
2017-06-30 19:47   ` [GSoC][PATCH 2/5 v3] submodule--helper: introduce for_each_submodule_list() Prathamesh Chavan
2017-06-30 19:47   ` [GSoC][PATCH 3/5 v3] submodule: port set_name_rev() from shell to C Prathamesh Chavan
2017-06-30 22:49     ` Junio C Hamano
2017-06-30 19:47   ` [GSoC][PATCH 4/5 v3] submodule: port submodule subcommand 'status' " Prathamesh Chavan
2017-06-30 23:08     ` Junio C Hamano
2017-06-30 19:47   ` [GSoC][PATCH 5/5 v3] submodule: port submodule subcommand 'sync' " Prathamesh Chavan
2017-06-30 20:11     ` Stefan Beller
2017-06-30 23:19     ` Junio C Hamano
2017-06-30 22:37   ` [GSoC][PATCH 1/5 v3] submodule--helper: introduce get_submodule_displaypath() Junio C Hamano
2017-07-13 20:05   ` [GSoC][PATCH 1/5 v4] " Prathamesh Chavan
2017-07-13 20:05     ` [GSoC][PATCH 2/5 v4] submodule--helper: introduce for_each_submodule_list() Prathamesh Chavan
2017-07-13 20:05     ` [GSoC][PATCH 3/5 v4] submodule: port set_name_rev() from shell to C Prathamesh Chavan
2017-07-13 20:05     ` [GSoC][PATCH 4/5 v4] submodule: port submodule subcommand 'status' " Prathamesh Chavan
2017-07-13 22:44       ` Stefan Beller
2017-07-13 20:05     ` [GSoC][PATCH 5/5 v4] submodule: port submodule subcommand 'sync' " Prathamesh Chavan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP8UFD1mdgtHWt0CD32O=jXPkGLBiba-41DUchT4WT7CheH4bA@mail.gmail.com' \
    --to=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pc44800@gmail.com \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).