From: Junio C Hamano Date: Fri, 19 Sep 2008 02:53:22 +0000 (-0700) Subject: Merge branch 'jc/maint-checkout-keep-remove' into maint X-Git-Tag: v1.6.0.3~78 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2ba3d5d9bd47c42400049e81d0e1e94948112277?ds=inline;hp=-c Merge branch 'jc/maint-checkout-keep-remove' into maint * jc/maint-checkout-keep-remove: checkout: do not lose staged removal --- 2ba3d5d9bd47c42400049e81d0e1e94948112277 diff --combined builtin-checkout.c index 8e77767b49,774f29992a..08c6d8614a --- a/builtin-checkout.c +++ b/builtin-checkout.c @@@ -76,15 -76,6 +76,15 @@@ static int read_tree_some(struct tree * return 0; } +static int skip_same_name(struct cache_entry *ce, int pos) +{ + while (++pos < active_nr && + !strcmp(active_cache[pos]->name, ce->name)) + ; /* skip */ + return pos; +} + + static int checkout_paths(struct tree *source_tree, const char **pathspec) { int pos; @@@ -116,20 -107,6 +116,20 @@@ if (report_path_error(ps_matched, pathspec, 0)) return 1; + /* Any unmerged paths? */ + for (pos = 0; pos < active_nr; pos++) { + struct cache_entry *ce = active_cache[pos]; + if (pathspec_match(pathspec, NULL, ce->name, 0)) { + if (!ce_stage(ce)) + continue; + errs = 1; + error("path '%s' is unmerged", ce->name); + pos = skip_same_name(ce, pos) - 1; + } + } + if (errs) + return 1; + /* Now we are committed to check them out */ memset(&state, 0, sizeof(state)); state.force = 1; @@@ -137,11 -114,7 +137,11 @@@ for (pos = 0; pos < active_nr; pos++) { struct cache_entry *ce = active_cache[pos]; if (pathspec_match(pathspec, NULL, ce->name, 0)) { - errs |= checkout_entry(ce, &state, NULL); + if (!ce_stage(ce)) { + errs |= checkout_entry(ce, &state, NULL); + continue; + } + pos = skip_same_name(ce, pos) - 1; } } @@@ -269,6 -242,8 +269,8 @@@ static int merge_working_tree(struct ch } /* 2-way merge to the new branch */ + topts.initial_checkout = (!active_nr && + (old->commit == new->commit)); topts.update = 1; topts.merge = 1; topts.gently = opts->merge; diff --combined builtin-read-tree.c index ac219ac2db,362216b272..0706c95818 --- a/builtin-read-tree.c +++ b/builtin-read-tree.c @@@ -64,7 -64,7 +64,7 @@@ static void prime_cache_tree(void } -static const char read_tree_usage[] = "git-read-tree ( | [[-m [--trivial] [--aggressive] | --reset | --prefix=] [-u | -i]] [--exclude-per-directory=] [--index-output=] [ []])"; +static const char read_tree_usage[] = "git read-tree ( | [[-m [--trivial] [--aggressive] | --reset | --prefix=] [-u | -i]] [--exclude-per-directory=] [--index-output=] [ []])"; static struct lock_file lock_file; @@@ -206,6 -206,7 +206,7 @@@ int cmd_read_tree(int argc, const char break; case 2: opts.fn = twoway_merge; + opts.initial_checkout = !active_nr; break; case 3: default: