Add "skip_unmerged" option to unpack_trees.
This option allows the caller to reset everything that isn't unmerged, leaving the unmerged things to be resolved. If, after a merge of "working" and "HEAD", this is used with "HEAD" (reset, !update), the result will be that all of the changes from "local" are in the working tree but not added to the index (either with the index clean but unchanged, or with the index unmerged, depending on whether there are conflicts). This will be used in checkout -m. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Daniel Barkalow committed
Feb 7, 2008 at 11:40 UTC
4e7c4571b8b31d6a09de2826361540caa76d3526
2 files changed
+18
-3
unpack-trees.c
+17
-3
@@ -85,6 +85,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
85
int any_dirs = 0;
86
char *cache_name;
87
int ce_stage;
88
+ int skip_entry = 0;
89
90
/* Find the first name in the input. */
91
@@ -153,6 +154,8 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
154
any_files = 1;
155
src[0] = active_cache[o->pos];
156
remove = o->pos;
157
+ if (o->skip_unmerged && ce_stage(src[0]))
158
+ skip_entry = 1;
159
}
160
161
for (i = 0; i < len; i++) {
@@ -181,6 +184,12 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
184
continue;
185
}
186
187
+ if (skip_entry) {
188
+ subposns[i] = df_conflict_list;
189
+ posns[i] = posns[i]->next;
190
+ continue;
191
+ }
192
+
193
if (!o->merge)
194
ce_stage = 0;
195
else if (i + 1 < o->head_idx)
@@ -205,7 +214,13 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
214
posns[i] = posns[i]->next;
215
}
216
if (any_files) {
208
- if (o->merge) {
217
+ if (skip_entry) {
218
+ o->pos++;
219
+ while (o->pos < active_nr &&
220
+ !strcmp(active_cache[o->pos]->name,
221
+ src[0]->name))
222
+ o->pos++;
223
+ } else if (o->merge) {
224
int ret;
225
226
#if DBRT_DEBUG > 1
@@ -730,9 +745,8 @@ int threeway_merge(struct cache_entry **stages,
745
* If we have an entry in the index cache, then we want to
746
* make sure that it matches head.
747
*/
733
- if (index && !same(index, head)) {
748
+ if (index && !same(index, head))
749
return o->gently ? -1 : reject_merge(index);
735
- }
750
751
if (head) {
752
/* #5ALT, #15 */
unpack-trees.h
+1
@@ -16,6 +16,7 @@ struct unpack_trees_options {
16
int trivial_merges_only;
17
int verbose_update;
18
int aggressive;
19
+ int skip_unmerged;
20
int gently;
21
const char *prefix;
22
int pos;