Skip to content

Commit

Permalink
read-tree --reset -u fix.
Browse files Browse the repository at this point in the history
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 <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed May 15, 2006
1 parent 613f027 commit 6d6776c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions read-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <sys/time.h>
#include <signal.h>

static int reset = 0;
static int merge = 0;
static int update = 0;
static int index_only = 0;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 6d6776c

Please sign in to comment.