1480
return ce;
1481
}
1482
1483
-static void check_ce_order(struct cache_entry *ce, struct cache_entry *next_ce)
1484
-{
1485
- int name_compare = strcmp(ce->name, next_ce->name);
1486
- if (0 < name_compare)
1487
- die("unordered stage entries in index");
1488
- if (!name_compare) {
1489
- if (!ce_stage(ce))
1490
- die("multiple stage entries for merged file '%s'",
1491
- ce->name);
1492
- if (ce_stage(ce) > ce_stage(next_ce))
1493
- die("unordered stage entries for '%s'",
1494
- ce->name);
1483
+static void check_ce_order(struct index_state *istate)
1484
+{
1485
+ unsigned int i;
1486
+
1487
+ for (i = 1; i < istate->cache_nr; i++) {
1488
+ struct cache_entry *ce = istate->cache[i - 1];
1489
+ struct cache_entry *next_ce = istate->cache[i];
1490
+ int name_compare = strcmp(ce->name, next_ce->name);
1491
+
1492
+ if (0 < name_compare)
1493
+ die("unordered stage entries in index");
1494
+ if (!name_compare) {
1495
+ if (!ce_stage(ce))
1496
+ die("multiple stage entries for merged file '%s'",
1497
+ ce->name);
1498
+ if (ce_stage(ce) > ce_stage(next_ce))
1499
+ die("unordered stage entries for '%s'",
1500
+ ce->name);
1501
+ }
1502
}
1503
}
1504
1563
ce = create_from_disk(disk_ce, &consumed, previous_name);
1564
set_index_entry(istate, i, ce);
1565
1559
- if (i > 0)
1560
- check_ce_order(istate->cache[i - 1], ce);
1561
-
1566
src_offset += consumed;
1567
}
1568
strbuf_release(&previous_name_buf);
1606
1607
ret = do_read_index(istate, path, 0);
1608
split_index = istate->split_index;
1605
- if (!split_index)
1606
- return ret;
1607
-
1608
- if (is_null_sha1(split_index->base_sha1))
1609
+ if (!split_index || is_null_sha1(split_index->base_sha1)) {
1610
+ check_ce_order(istate);
1611
return ret;
1612
+ }
1613
1614
if (split_index->base)
1615
discard_index(split_index->base);
1625
sha1_to_hex(split_index->base_sha1)),
1626
sha1_to_hex(split_index->base->sha1));
1627
merge_base_index(istate);
1628
+ check_ce_order(istate);
1629
return ret;
1630
}
1631