From 6d6776cb497ea7fbf5fe43912dbe3286f76c9933 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 15 May 2006 08:09:31 -0700 Subject: [PATCH] read-tree --reset -u fix. The previous commit makes -u to mean "I do want to remove the local changes, just update it from the read tree" only for one-way merge. It makes sense to have it depend on the "--reset" flag instead. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- read-tree.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/read-tree.c b/read-tree.c index 59b6a6bff..e16e91b17 100644 --- a/read-tree.c +++ b/read-tree.c @@ -12,6 +12,7 @@ #include #include +static int reset = 0; static int merge = 0; static int update = 0; static int index_only = 0; @@ -416,6 +417,10 @@ static void verify_uptodate(struct cache_entry *ce) return; errno = 0; } + if (reset) { + ce->ce_flags |= htons(CE_UPDATE); + return; + } if (errno == ENOENT) return; die("Entry '%s' not uptodate. Cannot merge.", ce->name); @@ -686,9 +691,12 @@ static int oneway_merge(struct cache_entry **src) if (!a) return deleted_entry(old, NULL); if (old && same(old, a)) { - struct stat st; - if (lstat(old->name, &st) || ce_match_stat(old, &st, 1)) - old->ce_flags |= htons(CE_UPDATE); + if (reset) { + struct stat st; + if (lstat(old->name, &st) || + ce_match_stat(old, &st, 1)) + old->ce_flags |= htons(CE_UPDATE); + } return keep_entry(old); } return merged_entry(a, NULL); @@ -722,7 +730,7 @@ static struct cache_file cache_file; int main(int argc, char **argv) { - int i, newfd, reset, stage = 0; + int i, newfd, stage = 0; unsigned char sha1[20]; merge_fn_t fn = NULL; -- 2.30.2