commit - f8aea23e895641029cc929e53148f3b8a85b13a1
commit + 74671950360a2118267670efd700a5328f3eeca4
blob - 78322cda13b90607e928a01b05c45a36e047d1c0
blob + f7ac2b2b5716ca262b954e9c56dd05936fc04e3f
--- include/got_diff.h
+++ include/got_diff.h
const struct got_error *got_diff_blob(struct got_blob_object *,
struct got_blob_object *, const char *, const char *, FILE *);
const struct got_error *got_diff_tree(struct got_tree_object *,
- struct got_tree_object *, struct got_repository *);
+ struct got_tree_object *, struct got_repository *, FILE *);
blob - 0cb5c034868325c64141658c3b8fc4ea9a7e5e2b
blob + 01ccbc4cb88041aa6126510584e0ba1f99bcda51
--- lib/diff.c
+++ lib/diff.c
}
static const struct got_error *
-diff_added_blob(struct got_object_id *id, struct got_repository *repo)
+diff_added_blob(struct got_object_id *id, struct got_repository *repo,
+ FILE *outfile)
{
const struct got_error *err;
struct got_blob_object *blob;
if (err != NULL)
return err;
- return got_diff_blob(NULL, blob, NULL, NULL, stdout);
+ return got_diff_blob(NULL, blob, NULL, NULL, outfile);
}
static const struct got_error *
diff_modified_blob(struct got_object_id *id1, struct got_object_id *id2,
- struct got_repository *repo)
+ struct got_repository *repo, FILE *outfile)
{
const struct got_error *err;
struct got_object *obj1 = NULL;
goto done;
}
- err = got_diff_blob(blob1, blob2, NULL, NULL, stdout);
+ err = got_diff_blob(blob1, blob2, NULL, NULL, outfile);
done:
if (obj1)
}
static const struct got_error *
-diff_deleted_blob(struct got_object_id *id, struct got_repository *repo)
+diff_deleted_blob(struct got_object_id *id, struct got_repository *repo,
+ FILE *outfile)
{
const struct got_error *err;
struct got_blob_object *blob;
if (err != NULL)
return err;
- return got_diff_blob(blob, NULL, NULL, NULL, stdout);
+ return got_diff_blob(blob, NULL, NULL, NULL, outfile);
}
static const struct got_error *
-diff_added_tree(struct got_object_id *id, struct got_repository *repo)
+diff_added_tree(struct got_object_id *id, struct got_repository *repo,
+ FILE *outfile)
{
const struct got_error *err = NULL;
struct got_object *treeobj = NULL;
if (err)
goto done;
- err = got_diff_tree(NULL, tree, repo);
+ err = got_diff_tree(NULL, tree, repo, outfile);
done:
if (tree)
static const struct got_error *
diff_modified_tree(struct got_object_id *id1, struct got_object_id *id2,
- struct got_repository *repo)
+ struct got_repository *repo, FILE *outfile)
{
const struct got_error *err = NULL;
struct got_object *treeobj1 = NULL;
if (err)
goto done;
- err = got_diff_tree(tree1, tree2, repo);
+ err = got_diff_tree(tree1, tree2, repo, outfile);
done:
if (tree1)
}
static const struct got_error *
-diff_deleted_tree(struct got_object_id *id, struct got_repository *repo)
+diff_deleted_tree(struct got_object_id *id, struct got_repository *repo, FILE *outfile)
{
const struct got_error *err = NULL;
struct got_object *treeobj = NULL;
if (err)
goto done;
- err = got_diff_tree(tree, NULL, repo);
+ err = got_diff_tree(tree, NULL, repo, outfile);
done:
if (tree)
}
static const struct got_error *
-diff_kind_mismatch(struct got_object_id *id1, struct got_object_id *id2)
+diff_kind_mismatch(struct got_object_id *id1, struct got_object_id *id2,
+ FILE *outfile)
{
/* XXX TODO */
return NULL;
static const struct got_error *
diff_entry_old_new(struct got_tree_entry *te1, struct got_tree_object *tree2,
- struct got_repository *repo)
+ struct got_repository *repo, FILE *outfile)
{
const struct got_error *err;
struct got_tree_entry *te2;
te2 = match_entry_by_name(te1, tree2);
if (te2 == NULL) {
if (S_ISDIR(te1->mode))
- return diff_deleted_tree(&te1->id, repo);
- return diff_deleted_blob(&te1->id, repo);
+ return diff_deleted_tree(&te1->id, repo, outfile);
+ return diff_deleted_blob(&te1->id, repo, outfile);
}
if (S_ISDIR(te1->mode) && S_ISDIR(te2->mode)) {
if (got_object_id_cmp(&te1->id, &te2->id) != 0)
- return diff_modified_tree(&te1->id, &te2->id, repo);
+ return diff_modified_tree(&te1->id, &te2->id, repo,
+ outfile);
} else if (S_ISREG(te1->mode) && S_ISREG(te2->mode)) {
if (got_object_id_cmp(&te1->id, &te2->id) != 0)
- return diff_modified_blob(&te1->id, &te2->id, repo);
+ return diff_modified_blob(&te1->id, &te2->id, repo,
+ outfile);
}
- return diff_kind_mismatch(&te1->id, &te2->id);
+ return diff_kind_mismatch(&te1->id, &te2->id, outfile);
}
static const struct got_error *
diff_entry_new_old(struct got_tree_entry *te2, struct got_tree_object *tree1,
- struct got_repository *repo)
+ struct got_repository *repo, FILE *outfile)
{
const struct got_error *err;
struct got_tree_entry *te1;
return NULL;
if (S_ISDIR(te2->mode))
- return diff_added_tree(&te2->id, repo);
- return diff_added_blob(&te2->id, repo);
+ return diff_added_tree(&te2->id, repo, outfile);
+ return diff_added_blob(&te2->id, repo, outfile);
}
const struct got_error *
got_diff_tree(struct got_tree_object *tree1, struct got_tree_object *tree2,
- struct got_repository *repo)
+ struct got_repository *repo, FILE *outfile)
{
const struct got_error *err = NULL;
struct got_tree_entry *te1 = NULL;
do {
if (te1) {
- err = diff_entry_old_new(te1, tree2, repo);
+ err = diff_entry_old_new(te1, tree2, repo, outfile);
if (err)
break;
}
if (te2) {
- err = diff_entry_new_old(te2, tree1, repo);
+ err = diff_entry_new_old(te2, tree1, repo, outfile);
if (err)
break;
}
blob - d3822a3873820aa50772dfe85626d4e8b02d5e2f
blob + 562ce42213964f4762d05de33601872bb8e3a7cc
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
return 0;
test_printf("\n");
- got_diff_tree(tree1, tree2, repo);
+ got_diff_tree(tree1, tree2, repo, stdout);
test_printf("\n");
got_object_tree_close(tree1);