X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=update-index.c;h=b825a11d2f6d8a53f5e42e4f157ba036a13edb59;hb=655c7470e2ea7f25f22703b6654d7570e1567a39;hp=01eaa1a984c606b3e5566a3aec588a394fd10e22;hpb=d710b2655c72f37f3d065b2c8c93e022f596d460;p=git.git diff --git a/update-index.c b/update-index.c index 01eaa1a9..b825a11d 100644 --- a/update-index.c +++ b/update-index.c @@ -13,7 +13,7 @@ * like "git-update-index *" and suddenly having all the object * files be revision controlled. */ -static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new = 0, quiet = 0, info_only = 0; +static int allow_add = 0, allow_remove = 0, allow_replace = 0, allow_unmerged = 0, not_new = 0, quiet = 0, info_only = 0; static int force_remove; /* Three functions to allow overloaded pointer return; see linux/err.h */ @@ -135,7 +135,7 @@ static struct cache_entry *refresh_entry(struct cache_entry *ce) changed = ce_match_stat(ce, &st); if (!changed) - return ce; + return NULL; if (ce_modified(ce, &st)) return ERR_PTR(-EINVAL); @@ -156,16 +156,20 @@ static int refresh_cache(void) struct cache_entry *ce, *new; ce = active_cache[i]; if (ce_stage(ce)) { - printf("%s: needs merge\n", ce->name); - has_errors = 1; while ((i < active_nr) && ! strcmp(active_cache[i]->name, ce->name)) i++; i--; + if (allow_unmerged) + continue; + printf("%s: needs merge\n", ce->name); + has_errors = 1; continue; } new = refresh_entry(ce); + if (!new) + continue; if (IS_ERR(new)) { if (not_new && PTR_ERR(new) == -ENOENT) continue; @@ -335,6 +339,10 @@ int main(int argc, const char **argv) allow_remove = 1; continue; } + if (!strcmp(path, "--unmerged")) { + allow_unmerged = 1; + continue; + } if (!strcmp(path, "--refresh")) { has_errors |= refresh_cache(); continue; @@ -383,9 +391,11 @@ int main(int argc, const char **argv) update_one(buf.buf, prefix, prefix_length); } } - if (write_cache(newfd, active_cache, active_nr) || - commit_index_file(&cache_file)) - die("Unable to write new cachefile"); + if (active_cache_changed) { + if (write_cache(newfd, active_cache, active_nr) || + commit_index_file(&cache_file)) + die("Unable to write new cachefile"); + } return has_errors ? 1 : 0; }