commit - a7331d50e5949de9db777b05789d7180d1082fd4
commit + 5fa52d6cdcc6de872ce3c7f6639cc638fd83eeea
blob - 9ada3529102e62be359b43263e1847b0fc5a7ccc
blob + 6f9c397cb5beed5d6de4ed2b82014650732b3318
--- lib/diff.c
+++ lib/diff.c
++ds->nfiles;
err = got_pathlist_append(ds->paths, path, change);
- if (err)
+ if (err) {
+ free(change);
return err;
+ }
pe = TAILQ_LAST(ds->paths, got_pathlist_head);
diffstat_field_width(&ds->max_path_len, &ds->add_cols, &ds->rm_cols,
char hex1[SHA1_DIGEST_STRING_LENGTH];
char hex2[SHA1_DIGEST_STRING_LENGTH];
const char *idstr1 = NULL, *idstr2 = NULL;
+ char *modestr1 = NULL, *modestr2 = NULL;
off_t size1, size2;
struct got_diffreg_result *result = NULL;
off_t outoff = 0;
idstr2 = "/dev/null";
if (outfile) {
- char *modestr1 = NULL, *modestr2 = NULL;
int modebits;
+
if (mode1 && mode1 != mode2) {
if (S_ISLNK(mode1))
modebits = S_IFLNK;
if (err)
goto done;
}
-
- free(modestr1);
- free(modestr2);
}
err = got_diffreg(&result, f1, f2, diff_algo, ignore_whitespace,
}
done:
+ free(modestr1);
+ free(modestr2);
if (resultp && err == NULL)
*resultp = result;
else if (result) {
if (tree2) {
te2 = got_object_tree_get_entry(tree2, 0);
if (te2 && asprintf(&l2, "%s%s%s", label2, label2[0] ? "/" : "",
- te2->name) == -1)
- return got_error_from_errno("asprintf");
+ te2->name) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
}
do {
if (te1) {
struct got_tree_entry *te = NULL;
+
if (tree2)
te = got_object_tree_find_entry(tree2,
te1->name);
free(l2);
l2 = NULL;
if (te && asprintf(&l2, "%s%s%s", label2,
- label2[0] ? "/" : "", te->name) == -1)
- return
- got_error_from_errno("asprintf");
+ label2[0] ? "/" : "", te->name) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
}
+
err = diff_entry_old_new(te1, te, f1, f2, fd1, fd2,
l1, l2, repo, cb, cb_arg, diff_content);
if (err)
if (te2) {
struct got_tree_entry *te = NULL;
+
if (tree1)
te = got_object_tree_find_entry(tree1,
te2->name);
+
free(l2);
+ l2 = NULL;
if (te) {
if (asprintf(&l2, "%s%s%s", label2,
- label2[0] ? "/" : "", te->name) == -1)
- return
- got_error_from_errno("asprintf");
+ label2[0] ? "/" : "", te->name) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
} else {
if (asprintf(&l2, "%s%s%s", label2,
- label2[0] ? "/" : "", te2->name) == -1)
- return
- got_error_from_errno("asprintf");
+ label2[0] ? "/" : "", te2->name) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
}
+
err = diff_entry_new_old(te2, te, f1, f2, fd2, l2,
repo, cb, cb_arg, diff_content);
if (err)
te1 = got_object_tree_get_entry(tree1, tidx1);
if (te1 &&
asprintf(&l1, "%s%s%s", label1,
- label1[0] ? "/" : "", te1->name) == -1)
- return got_error_from_errno("asprintf");
+ label1[0] ? "/" : "", te1->name) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
}
+
free(l2);
l2 = NULL;
if (te2) {
te2 = got_object_tree_get_entry(tree2, tidx2);
if (te2 &&
asprintf(&l2, "%s%s%s", label2,
- label2[0] ? "/" : "", te2->name) == -1)
- return got_error_from_errno("asprintf");
+ label2[0] ? "/" : "", te2->name) == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
}
} while (te1 || te2);
+done:
+ free(l1);
+ free(l2);
return err;
}
*resultp = diffreg_result;
else if (diffreg_result) {
const struct got_error *free_err;
+
free_err = got_diffreg_result_free(diffreg_result);
if (free_err && err == NULL)
err = free_err;