summaryrefslogtreecommitdiff
path: root/merge-ort.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2021-01-19 19:53:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-21 06:18:55 (GMT)
commit1b6b902d95a5b2c5677b6351c670202dae7cd230 (patch)
tree468e4cbc748f450010033fe03e8a6d056a0643d1 /merge-ort.c
parent089d82bc18514d78513a85e95de257f74da18205 (diff)
downloadgit-1b6b902d95a5b2c5677b6351c670202dae7cd230.zip
git-1b6b902d95a5b2c5677b6351c670202dae7cd230.tar.gz
git-1b6b902d95a5b2c5677b6351c670202dae7cd230.tar.bz2
merge-ort: process_renames() now needs more defensiveness
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-ort.c')
-rw-r--r--merge-ort.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/merge-ort.c b/merge-ort.c
index 1152d0a..7314f9c 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -1410,12 +1410,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