Skip to content

Commit

Permalink
xmerge: make return value from xdl_merge() more usable.
Browse files Browse the repository at this point in the history
The callers would want to know if the resulting merge is clean;
do not discard that information away after calling xdl_do_merge().

Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Junio C Hamano committed Dec 3, 2006
1 parent 857b933 commit 53a7085
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions xdiff/xmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
xpparam_t const *xpp, int level, mmbuffer_t *result) {
xdchange_t *xscr1, *xscr2;
xdfenv_t xe1, xe2;
int status;

result->ptr = NULL;
result->size = 0;
Expand All @@ -404,6 +405,7 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
xdl_free_env(&xe2);
return -1;
}
status = 0;
if (xscr1 || xscr2) {
if (!xscr1) {
result->ptr = xdl_malloc(mf2->size);
Expand All @@ -413,21 +415,16 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
result->ptr = xdl_malloc(mf1->size);
memcpy(result->ptr, mf1->ptr, mf1->size);
result->size = mf1->size;
} else if (xdl_do_merge(&xe1, xscr1, name1,
&xe2, xscr2, name2,
level, xpp, result) < 0) {
xdl_free_script(xscr1);
xdl_free_script(xscr2);
xdl_free_env(&xe1);
xdl_free_env(&xe2);
return -1;
} else {
status = xdl_do_merge(&xe1, xscr1, name1,
&xe2, xscr2, name2,
level, xpp, result);
}
xdl_free_script(xscr1);
xdl_free_script(xscr2);
}
xdl_free_env(&xe1);
xdl_free_env(&xe2);

return 0;
return status;
}

0 comments on commit 53a7085

Please sign in to comment.