Blame


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