wincred: avoid overwriting configured variables
[gitweb.git] / builtin / mv.c
index 08fbc033e45bba4880c8de797ef5ac0dc0b6259d..45e57f307b799490a949d60b37f8cff1a1e5d07f 100644 (file)
@@ -179,6 +179,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                                modes = xrealloc(modes,
                                                                (argc + last - first)
                                                                * sizeof(enum update_mode));
+                                               submodule_gitfile = xrealloc(submodule_gitfile,
+                                                               (argc + last - first)
+                                                               * sizeof(char *));
                                        }
 
                                        dst = add_slash(dst);
@@ -192,6 +195,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                                        prefix_path(dst, dst_len,
                                                                path + length + 1);
                                                modes[argc + j] = INDEX;
+                                               submodule_gitfile[argc + j] = NULL;
                                        }
                                        argc += last - first;
                                }
@@ -214,6 +218,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                        }
                } else if (string_list_has_string(&src_for_dst, dst))
                        bad = _("multiple sources for the same target");
+               else if (is_dir_sep(dst[strlen(dst) - 1]))
+                       bad = _("destination directory does not exist");
                else
                        string_list_insert(&src_for_dst, dst);
 
@@ -225,6 +231,11 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                        memmove(destination + i,
                                                destination + i + 1,
                                                (argc - i) * sizeof(char *));
+                                       memmove(modes + i, modes + i + 1,
+                                               (argc - i) * sizeof(enum update_mode));
+                                       memmove(submodule_gitfile + i,
+                                               submodule_gitfile + i + 1,
+                                               (argc - i) * sizeof(char *));
                                        i--;
                                }
                        } else