X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-update-index.c;h=3ab214d24e537865875d6d1e3acd8cf6b019ff22;hb=cd8e3711bf2dce3e2d18aac41e7f42242fbba338;hp=a64a752990b85b69590cdbeed3901154642007b8;hpb=f922df8655675aafaea96f3715c9473c63d2ca47;p=git.git diff --git a/builtin-update-index.c b/builtin-update-index.c index a64a75299..3ab214d24 100644 --- a/builtin-update-index.c +++ b/builtin-update-index.c @@ -9,6 +9,7 @@ #include "tree-walk.h" #include "builtin.h" #include "refs.h" +#include "resolve-undo.h" /* * Default to not allowing changes to the list of files. The @@ -440,7 +441,18 @@ static int unresolve_one(const char *path) /* See if there is such entry in the index. */ pos = cache_name_pos(path, namelen); - if (pos < 0) { + if (0 <= pos) { + /* already merged */ + pos = unmerge_cache_entry_at(pos); + if (pos < active_nr) { + struct cache_entry *ce = active_cache[pos]; + if (ce_stage(ce) && + ce_namelen(ce) == namelen && + !memcmp(ce->name, path, namelen)) + return 0; + } + /* no resolve-undo information; fall back */ + } else { /* If there isn't, either it is unmerged, or * resolved as "removed" by mistake. We do not * want to do anything in the former case. @@ -719,6 +731,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) verbose = 1; continue; } + if (!strcmp(path, "--clear-resolve-undo")) { + resolve_undo_clear(); + continue; + } if (!strcmp(path, "-h") || !strcmp(path, "--help")) usage(update_index_usage); die("unknown option %s", path);