summaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-09-10 09:13:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-09-10 09:13:41 (GMT)
commit94c27881bd98d5bb70e3d4f8a18e384095c876b9 (patch)
treeafb52cefd82080596aa910bb3e84b75e1d10ee9a /builtin-checkout.c
parent9f35e5fd544ab87488b12d9b97be983303e58bd2 (diff)
parent8fdcf3125465f70c0cad5be5ab192d46e46307c7 (diff)
downloadgit-94c27881bd98d5bb70e3d4f8a18e384095c876b9.zip
git-94c27881bd98d5bb70e3d4f8a18e384095c876b9.tar.gz
git-94c27881bd98d5bb70e3d4f8a18e384095c876b9.tar.bz2
Merge branch 'jc/maint-checkout-fix' into maint
* jc/maint-checkout-fix: checkout: do not check out unmerged higher stages randomly
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index f6f8f08..8e77767 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -76,6 +76,15 @@ static int read_tree_some(struct tree *tree, const char **pathspec)
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;
@@ -107,6 +116,20 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec)
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;
@@ -114,7 +137,11 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec)
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;
}
}