From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Elijah Newren <newren@gmail.com>
Subject: [PATCH 16/17] merge-ort: process_renames() now needs more defensiveness
Date: Mon, 4 Jan 2021 15:50:05 -0800 [thread overview]
Message-ID: <20210104235006.2867404-17-newren@gmail.com> (raw)
In-Reply-To: <20210104235006.2867404-1-newren@gmail.com>
Since directory rename detection adds new paths to opt->priv->paths and
removes old ones, process_renames() needs to now check whether
pair->one->path actually exists in opt->priv->paths instead of just
assuming it does.
Signed-off-by: Elijah Newren <newren@gmail.com>
---
merge-ort.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/merge-ort.c b/merge-ort.c
index 115ff6d2d5..480f212cff 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -1829,12 +1829,28 @@ static int process_renames(struct merge_options *opt,
const char *rename_branch = NULL, *delete_branch = NULL;
old_ent = strmap_get_entry(&opt->priv->paths, pair->one->path);
- oldpath = old_ent->key;
- oldinfo = old_ent->value;
-
new_ent = strmap_get_entry(&opt->priv->paths, pair->two->path);
- newpath = new_ent->key;
- newinfo = new_ent->value;
+ if (old_ent) {
+ oldpath = old_ent->key;
+ oldinfo = old_ent->value;
+ }
+ newpath = pair->two->path;
+ if (new_ent) {
+ newpath = new_ent->key;
+ newinfo = new_ent->value;
+ }
+
+ /*
+ * If pair->one->path isn't in opt->priv->paths, that means
+ * that either directory rename detection removed that
+ * path, or a parent directory of oldpath was resolved and
+ * we don't even need the rename; in either case, we can
+ * skip it. If oldinfo->merged.clean, then the other side
+ * of history had no changes to oldpath and we don't need
+ * the rename and can skip it.
+ */
+ if (!oldinfo || oldinfo->merged.clean)
+ continue;
/*
* diff_filepairs have copies of pathnames, thus we have to
--
2.29.1.106.g3ff750dc32.dirty
next prev parent reply other threads:[~2021-01-04 23:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-04 23:49 [PATCH 00/17] Add directory rename detection to merge-ort Elijah Newren
2021-01-04 23:49 ` [PATCH 01/17] merge-ort: add new data structures for directory rename detection Elijah Newren
2021-01-04 23:49 ` [PATCH 02/17] merge-ort: initialize and free new directory rename data structures Elijah Newren
2021-01-04 23:49 ` [PATCH 03/17] merge-ort: collect which directories are removed in dirs_removed Elijah Newren
2021-01-04 23:49 ` [PATCH 04/17] merge-ort: add outline for computing directory renames Elijah Newren
2021-01-04 23:49 ` [PATCH 05/17] merge-ort: add outline of get_provisional_directory_renames() Elijah Newren
2021-01-04 23:49 ` [PATCH 06/17] merge-ort: copy get_renamed_dir_portion() from merge-recursive.c Elijah Newren
2021-01-04 23:49 ` [PATCH 07/17] merge-ort: implement compute_rename_counts() Elijah Newren
2021-01-04 23:49 ` [PATCH 08/17] merge-ort: implement handle_directory_level_conflicts() Elijah Newren
2021-01-04 23:49 ` [PATCH 09/17] merge-ort: modify collect_renames() for directory rename handling Elijah Newren
2021-01-04 23:49 ` [PATCH 10/17] merge-ort: implement compute_collisions() Elijah Newren
2021-01-04 23:50 ` [PATCH 11/17] merge-ort: implement apply_dir_rename() and check_dir_renamed() Elijah Newren
2021-01-04 23:50 ` [PATCH 12/17] merge-ort: implement check_for_directory_rename() Elijah Newren
2021-01-04 23:50 ` [PATCH 13/17] merge-ort: implement handle_path_level_conflicts() Elijah Newren
2021-01-04 23:50 ` [PATCH 14/17] merge-ort: add a new toplevel_dir field Elijah Newren
2021-01-04 23:50 ` [PATCH 15/17] merge-ort: implement apply_directory_rename_modifications() Elijah Newren
2021-01-04 23:50 ` Elijah Newren [this message]
2021-01-04 23:50 ` [PATCH 17/17] merge-ort: fix a directory rename detection bug Elijah Newren
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=20210104235006.2867404-17-newren@gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).