Blob


1 /*
2 * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 /*
18 * Compute the differences between two blobs and write unified diff text
19 * to the provided output FILE. Two const char * diff header labels may
20 * be provided which will be used to identify each blob in the diff output.
21 * If a label is NULL, use the blob's SHA1 checksum instead.
22 * The number of context lines to show in the diff must be specified as well.
23 */
24 const struct got_error *got_diff_blob(struct got_blob_object *,
25 struct got_blob_object *, const char *, const char *, int, FILE *);
27 /*
28 * Compute the differences between a blob and a file and write unified diff
29 * text to the provided output file. The file's size must be provided, as
30 * well as a const char * diff header label which identifies the file.
31 * The number of context lines to show in the diff must be specified as well.
32 */
33 const struct got_error *
34 got_diff_blob_file(struct got_blob_object *, FILE *, size_t, const char *, int,
35 FILE *);
37 /*
38 * Compute the differences between two trees and write unified diff text
39 * to the provided output FILE. Two const char * diff header labels may
40 * be provided which will be used to identify each blob in the diff output.
41 * If a label is NULL, use the blob's SHA1 checksum instead.
42 * The number of context lines to show in the diff must be specified as well.
43 */
44 const struct got_error *got_diff_tree(struct got_tree_object *,
45 struct got_tree_object *, const char *label1, const char *label2,
46 int, struct got_repository *, FILE *);
48 /*
49 * Diff two objects, assuming both objects are blobs. Two const char * diff
50 * header labels may be provided which will be used to identify each blob in
51 * the diff output. If a label is NULL, use the blob's SHA1 checksum instead.
52 * The number of context lines to show in the diff must be specified as well.
53 * Write unified diff text to the provided output FILE.
54 */
55 const struct got_error *got_diff_objects_as_blobs(struct got_object_id *,
56 struct got_object_id *, const char *, const char *, int,
57 struct got_repository *, FILE *);
59 /*
60 * Diff two objects, assuming both objects are trees. Two const char * diff
61 * header labels may be provided which will be used to identify each blob in
62 * the trees. If a label is NULL, use the blob's SHA1 checksum instead.
63 * The number of context lines to show in diffs must be specified.
64 * Write unified diff text to the provided output FILE.
65 */
66 const struct got_error *got_diff_objects_as_trees(struct got_object_id *,
67 struct got_object_id *, char *, char *, int, struct got_repository *, FILE *);
69 /*
70 * Diff two objects, assuming both objects are commits.
71 * The number of context lines to show in diffs must be specified.
72 * Write unified diff text to the provided output FILE.
73 */
74 const struct got_error *got_diff_objects_as_commits(struct got_object_id *,
75 struct got_object_id *, int, struct got_repository *, FILE *);
77 #define GOT_DIFF_MAX_CONTEXT 64