Skip to content

Commit

Permalink
Add "skip_unmerged" option to unpack_trees.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Barkalow authored and Junio C Hamano committed Feb 10, 2008
1 parent 33ecf7e commit 4e7c457
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
int any_dirs = 0;
char *cache_name;
int ce_stage;
int skip_entry = 0;

/* Find the first name in the input. */

Expand Down Expand Up @@ -153,6 +154,8 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
any_files = 1;
src[0] = active_cache[o->pos];
remove = o->pos;
if (o->skip_unmerged && ce_stage(src[0]))
skip_entry = 1;
}

for (i = 0; i < len; i++) {
Expand Down Expand Up @@ -181,6 +184,12 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
continue;
}

if (skip_entry) {
subposns[i] = df_conflict_list;
posns[i] = posns[i]->next;
continue;
}

if (!o->merge)
ce_stage = 0;
else if (i + 1 < o->head_idx)
Expand All @@ -205,7 +214,13 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
posns[i] = posns[i]->next;
}
if (any_files) {
if (o->merge) {
if (skip_entry) {
o->pos++;
while (o->pos < active_nr &&
!strcmp(active_cache[o->pos]->name,
src[0]->name))
o->pos++;
} else if (o->merge) {
int ret;

#if DBRT_DEBUG > 1
Expand Down Expand Up @@ -730,9 +745,8 @@ int threeway_merge(struct cache_entry **stages,
* If we have an entry in the index cache, then we want to
* make sure that it matches head.
*/
if (index && !same(index, head)) {
if (index && !same(index, head))
return o->gently ? -1 : reject_merge(index);
}

if (head) {
/* #5ALT, #15 */
Expand Down
1 change: 1 addition & 0 deletions unpack-trees.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct unpack_trees_options {
int trivial_merges_only;
int verbose_update;
int aggressive;
int skip_unmerged;
int gently;
const char *prefix;
int pos;
Expand Down

0 comments on commit 4e7c457

Please sign in to comment.