From: Jacob Keller <jacob.keller@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: Git mailing list <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Jens Lehmann <Jens.Lehmann@web.de>,
gmane@otterhall.com
Subject: Re: [PATCH 2/2] mv: allow moving nested submodules
Date: Tue, 19 Apr 2016 00:13:32 -0700 [thread overview]
Message-ID: <CA+P7+xrzH3gMWsCBmW9y40AFOEfUxMQR+s8O05ofMN09nF_Pkw@mail.gmail.com> (raw)
In-Reply-To: <1461022884-30819-3-git-send-email-sbeller@google.com>
On Mon, Apr 18, 2016 at 4:41 PM, Stefan Beller <sbeller@google.com> wrote:
> When directories are moved using `git mv` all files in the directory
> have been just moved, but no further action was taken on them. This
> was done by assigning the mode = WORKING_DIRECTORY to the files
> inside a moved directory.
>
> submodules however need to update their link to the git directory as
> well as updates to the .gitmodules file. By removing the condition of
> `mode != INDEX` (the remaining modes are BOTH and WORKING_DIRECTORY) for
> the required submodule actions, we perform these for submodules in a
> moved directory.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
The patch looks good to me. I've marked some comments that I thought
through while reviewing but it looks correct.
> ---
> builtin/mv.c | 39 ++++++++++++++++++++++-----------------
> t/t7001-mv.sh | 16 ++++++++++++++++
> 2 files changed, 38 insertions(+), 17 deletions(-)
>
> diff --git a/builtin/mv.c b/builtin/mv.c
> index 74516f4..2deb95b 100644
> --- a/builtin/mv.c
> +++ b/builtin/mv.c
> @@ -253,23 +253,28 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
> int pos;
> if (show_only || verbose)
> printf(_("Renaming %s to %s\n"), src, dst);
> - if (!show_only && mode != INDEX) {
> - if (rename(src, dst) < 0 && !ignore_errors)
> - die_errno(_("renaming '%s' failed"), src);
> - if (submodule_gitfile[i]) {
> - if ((submodule_gitfile[i] != SUBMODULE_WITH_GITDIR &&
> - connect_work_tree_and_git_dir(dst, submodule_gitfile[i], &err)) ||
> - update_path_in_gitmodules(src, dst, &err)) {
> - if (err.len) {
> - if (ignore_errors) {
> - warning("%s", err.buf);
> - continue;
> - } else
> - die("%s", err.buf);
> - }
> - } else
> - gitmodules_modified = 1;
> - }
> + if (show_only)
> + continue;
So here, we skip the item after displaying when we're in show only
mode. That seems correct.
> + if (mode != INDEX &&
> + rename(src, dst) < 0) {
> + if (ignore_errors)
> + continue;
> + die_errno(_("renaming '%s' failed"), src);
> + }
Then when the mode isn't INDEX, we attempt the rename.
> +
> + if (submodule_gitfile[i]) {
> + if ((submodule_gitfile[i] != SUBMODULE_WITH_GITDIR &&
> + connect_work_tree_and_git_dir(dst, submodule_gitfile[i], &err)) ||
> + update_path_in_gitmodules(src, dst, &err)) {
> + if (err.len) {
> + if (ignore_errors) {
> + warning("%s", err.buf);
> + continue;
> + } else
> + die("%s", err.buf);
> + }
> + } else
> + gitmodules_modified = 1;
> }
Finally for all modes, we perform the steps for submodules. That makes
sense to me.
>
This version results in a much larger diff, but I think the resulting
code is much easier to follow. The use of the continue allows us to
drop a layer of indentation making the remaining code a bit easier on
the eyes. The patch description doesn't at first glance match the code
change, since now it's a much larger chunk of moved code. However on
inspection, I don't think anything needs to change, as it's just the
conversion to if (show_only) { continue; }
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Thanks,
Jake
next prev parent reply other threads:[~2016-04-19 7:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 23:41 [PATCH 0/2] WAS: [PATCH] mv: allow moving nested submodules Stefan Beller
2016-04-18 23:41 ` [PATCH 1/2] mv submodule: respect ignore_errors for errors in submodule code Stefan Beller
2016-04-18 23:41 ` [PATCH 2/2] mv: allow moving nested submodules Stefan Beller
2016-04-19 7:13 ` Jacob Keller [this message]
2016-04-19 0:01 ` [PATCH 0/2] WAS: [PATCH] " Junio C Hamano
2016-04-19 16:56 ` Stefan Beller
2016-04-19 18:15 ` Junio C Hamano
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=CA+P7+xrzH3gMWsCBmW9y40AFOEfUxMQR+s8O05ofMN09nF_Pkw@mail.gmail.com \
--to=jacob.keller@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=gmane@otterhall.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).