Commit Diff


commit - f8aea23e895641029cc929e53148f3b8a85b13a1
commit + 74671950360a2118267670efd700a5328f3eeca4
blob - 78322cda13b90607e928a01b05c45a36e047d1c0
blob + f7ac2b2b5716ca262b954e9c56dd05936fc04e3f
--- include/got_diff.h
+++ include/got_diff.h
@@ -17,4 +17,4 @@
 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
@@ -134,7 +134,8 @@ match_entry_by_name(struct got_tree_entry *te1, struct
 }
 
 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;
@@ -147,12 +148,12 @@ diff_added_blob(struct got_object_id *id, struct got_r
 	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;
@@ -190,7 +191,7 @@ diff_modified_blob(struct got_object_id *id1, struct g
 		goto done;
 	}
 
-	err = got_diff_blob(blob1, blob2, NULL, NULL, stdout);
+	err = got_diff_blob(blob1, blob2, NULL, NULL, outfile);
 
 done:
 	if (obj1)
@@ -205,7 +206,8 @@ done:
 }
 
 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;
@@ -218,11 +220,12 @@ diff_deleted_blob(struct got_object_id *id, struct got
 	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;
@@ -241,7 +244,7 @@ diff_added_tree(struct got_object_id *id, struct got_r
 	if (err)
 		goto done;
 
-	err = got_diff_tree(NULL, tree, repo);
+	err = got_diff_tree(NULL, tree, repo, outfile);
 
 done:
 	if (tree)
@@ -253,7 +256,7 @@ done:
 
 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;
@@ -287,7 +290,7 @@ diff_modified_tree(struct got_object_id *id1, struct g
 	if (err)
 		goto done;
 
-	err = got_diff_tree(tree1, tree2, repo);
+	err = got_diff_tree(tree1, tree2, repo, outfile);
 
 done:
 	if (tree1)
@@ -302,7 +305,7 @@ done:
 }
 
 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;
@@ -321,7 +324,7 @@ diff_deleted_tree(struct got_object_id *id, struct got
 	if (err)
 		goto done;
 
-	err = got_diff_tree(tree, NULL, repo);
+	err = got_diff_tree(tree, NULL, repo, outfile);
 
 done:
 	if (tree)
@@ -332,7 +335,8 @@ done:
 }
 
 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;
@@ -340,7 +344,7 @@ diff_kind_mismatch(struct got_object_id *id1, struct g
 
 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;
@@ -349,24 +353,26 @@ diff_entry_old_new(struct got_tree_entry *te1, struct 
 	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;
@@ -376,13 +382,13 @@ diff_entry_new_old(struct got_tree_entry *te2, struct 
 		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;
@@ -395,13 +401,13 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 
 	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
@@ -385,7 +385,7 @@ repo_diff_tree(const char *repo_path)
 		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);