summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 79f5e06)
raw | patch | inline | side by side (parent: 79f5e06)
author | Linus Torvalds <torvalds@linux-foundation.org> | |
Fri, 10 Aug 2007 19:15:54 +0000 (12:15 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 10 Aug 2007 20:59:19 +0000 (13:59 -0700) |
This makes no changes to current code, but it allows the individual merge
functions to decide what to do about the old entry. They might decide to
update it in place, rather than force them to always delete and re-add it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
functions to decide what to do about the old entry. They might decide to
update it in place, rather than force them to always delete and re-add it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees.c | patch | blob | history | |
unpack-trees.h | patch | blob | history |
diff --git a/unpack-trees.c b/unpack-trees.c
index 5d1ffd1a32a56bdcf4f64b545abd6aa951914ffe..5e457b0bc919c746405a0ec106cdc02d47fd1ff9 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
return ret;
}
+static inline void remove_entry(int remove)
+{
+ if (remove >= 0)
+ remove_cache_entry_at(remove);
+}
+
static int unpack_trees_rec(struct tree_entry_list **posns, int len,
const char *base, struct unpack_trees_options *o,
struct tree_entry_list *df_conflict_list)
{
+ int remove;
int baselen = strlen(base);
int src_size = len + 1;
int i_stk = i_stk;
subposns = xcalloc(len, sizeof(struct tree_list_entry *));
+ remove = -1;
if (cache_name && !strcmp(cache_name, first)) {
any_files = 1;
src[0] = active_cache[o->pos];
- remove_cache_entry_at(o->pos);
+ remove = o->pos;
}
for (i = 0; i < len; i++) {
printf("\n");
}
#endif
- ret = o->fn(src, o);
+ ret = o->fn(src, o, remove);
#if DBRT_DEBUG > 1
printf("Added %d entries\n", ret);
#endif
o->pos += ret;
} else {
+ remove_entry(remove);
for (i = 0; i < src_size; i++) {
if (src[i]) {
add_cache_entry(src[i], ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK);
#endif
int threeway_merge(struct cache_entry **stages,
- struct unpack_trees_options *o)
+ struct unpack_trees_options *o,
+ int remove)
{
struct cache_entry *index;
struct cache_entry *head;
int no_anc_exists = 1;
int i;
+ remove_entry(remove);
for (i = 1; i < o->head_idx; i++) {
if (!stages[i] || stages[i] == o->df_conflict_entry)
any_anc_missing = 1;
*
*/
int twoway_merge(struct cache_entry **src,
- struct unpack_trees_options *o)
+ struct unpack_trees_options *o,
+ int remove)
{
struct cache_entry *current = src[0];
struct cache_entry *oldtree = src[1];
struct cache_entry *newtree = src[2];
+ remove_entry(remove);
if (o->merge_size != 2)
return error("Cannot do a twoway merge of %d trees",
o->merge_size);
* stage0 does not have anything there.
*/
int bind_merge(struct cache_entry **src,
- struct unpack_trees_options *o)
+ struct unpack_trees_options *o,
+ int remove)
{
struct cache_entry *old = src[0];
struct cache_entry *a = src[1];
+ remove_entry(remove);
if (o->merge_size != 1)
return error("Cannot do a bind merge of %d trees\n",
o->merge_size);
* - take the stat information from stage0, take the data from stage1
*/
int oneway_merge(struct cache_entry **src,
- struct unpack_trees_options *o)
+ struct unpack_trees_options *o,
+ int remove)
{
struct cache_entry *old = src[0];
struct cache_entry *a = src[1];
+ remove_entry(remove);
if (o->merge_size != 1)
return error("Cannot do a oneway merge of %d trees",
o->merge_size);
diff --git a/unpack-trees.h b/unpack-trees.h
index 9cd39a28a907ef6f0eedc764bbae586353ec2ca5..5517faafad6ca3f327c81ab6e8e5f2701ff0ad14 100644 (file)
--- a/unpack-trees.h
+++ b/unpack-trees.h
struct unpack_trees_options;
typedef int (*merge_fn_t)(struct cache_entry **src,
- struct unpack_trees_options *options);
+ struct unpack_trees_options *options,
+ int remove);
struct unpack_trees_options {
int reset;
extern int unpack_trees(unsigned n, struct tree_desc *t,
struct unpack_trees_options *options);
-int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o);
-int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o);
-int bind_merge(struct cache_entry **src, struct unpack_trees_options *o);
-int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o);
+int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o, int);
+int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o, int);
+int bind_merge(struct cache_entry **src, struct unpack_trees_options *o, int);
+int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o, int);
#endif