diff options
author | Russell Belfer <rb@github.com> | 2012-09-25 16:31:46 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-09-25 16:35:05 -0700 |
commit | bae957b95d59a840df72a725b06f00635471cfd8 (patch) | |
tree | 64eb7f9f52c9d27f4aa0ad00d2249af39e0ee2fc /src | |
parent | 642863086575a61b3ed0bbbe909f4f07d87ff9db (diff) | |
download | libgit2-bae957b95d59a840df72a725b06f00635471cfd8.tar.gz |
Add const to all shared pointers in diff API
There are a lot of places where the diff API gives the user access
to internal data structures and many of these were being exposed
through non-const pointers. This replaces them all with const
pointers for any object that the user can access but is still
owned internally to the git_diff_list or git_diff_patch objects.
This will probably break some bindings... Sorry!
Diffstat (limited to 'src')
-rw-r--r-- | src/checkout.c | 4 | ||||
-rw-r--r-- | src/diff.c | 2 | ||||
-rw-r--r-- | src/diff.h | 2 | ||||
-rw-r--r-- | src/diff_output.c | 34 | ||||
-rw-r--r-- | src/diff_output.h | 2 |
5 files changed, 23 insertions, 21 deletions
diff --git a/src/checkout.c b/src/checkout.c index 7cf9fe033..e429d2876 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -126,7 +126,7 @@ static int blob_content_to_link(git_blob *blob, const char *path, bool can_symli static int checkout_blob( git_repository *repo, - git_oid *blob_oid, + const git_oid *blob_oid, const char *path, mode_t filemode, bool can_symlink, @@ -150,7 +150,7 @@ static int checkout_blob( static int checkout_diff_fn( void *cb_data, - git_diff_delta *delta, + const git_diff_delta *delta, float progress) { struct checkout_diff_data *data; diff --git a/src/diff.c b/src/diff.c index 7ee919b5a..4dedbe831 100644 --- a/src/diff.c +++ b/src/diff.c @@ -809,7 +809,7 @@ on_error: bool git_diff_delta__should_skip( - git_diff_options *opts, git_diff_delta *delta) + const git_diff_options *opts, const git_diff_delta *delta) { uint32_t flags = opts ? opts->flags : 0; diff --git a/src/diff.h b/src/diff.h index 64fe00928..15745b2f3 100644 --- a/src/diff.h +++ b/src/diff.h @@ -51,7 +51,7 @@ extern void git_diff__cleanup_modes( extern void git_diff_list_addref(git_diff_list *diff); extern bool git_diff_delta__should_skip( - git_diff_options *opts, git_diff_delta *delta); + const git_diff_options *opts, const git_diff_delta *delta); #endif diff --git a/src/diff_output.c b/src/diff_output.c index 141859742..05bca4668 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -177,7 +177,7 @@ static int diff_delta_is_binary_by_size( } static void setup_xdiff_options( - git_diff_options *opts, xdemitconf_t *cfg, xpparam_t *param) + const git_diff_options *opts, xdemitconf_t *cfg, xpparam_t *param) { memset(cfg, 0, sizeof(xdemitconf_t)); memset(param, 0, sizeof(xpparam_t)); @@ -371,7 +371,7 @@ static void diff_context_init( diff_context *ctxt, git_diff_list *diff, git_repository *repo, - git_diff_options *opts, + const git_diff_options *opts, void *data, git_diff_file_fn file_cb, git_diff_hunk_fn hunk_cb, @@ -696,8 +696,8 @@ static void diff_patch_free(git_diff_patch *patch) static int diff_patch_hunk_cb( void *cb_data, - git_diff_delta *delta, - git_diff_range *range, + const git_diff_delta *delta, + const git_diff_range *range, const char *header, size_t header_len) { @@ -743,8 +743,8 @@ static int diff_patch_hunk_cb( static int diff_patch_line_cb( void *cb_data, - git_diff_delta *delta, - git_diff_range *range, + const git_diff_delta *delta, + const git_diff_range *range, char line_origin, const char *content, size_t content_len) @@ -905,7 +905,8 @@ char git_diff_status_char(git_delta_t status) return code; } -static int print_compact(void *data, git_diff_delta *delta, float progress) +static int print_compact( + void *data, const git_diff_delta *delta, float progress) { diff_print_info *pi = data; char old_suffix, new_suffix, code = git_diff_status_char(delta->status); @@ -967,7 +968,7 @@ int git_diff_print_compact( return error; } -static int print_oid_range(diff_print_info *pi, git_diff_delta *delta) +static int print_oid_range(diff_print_info *pi, const git_diff_delta *delta) { char start_oid[8], end_oid[8]; @@ -997,7 +998,8 @@ static int print_oid_range(diff_print_info *pi, git_diff_delta *delta) return 0; } -static int print_patch_file(void *data, git_diff_delta *delta, float progress) +static int print_patch_file( + void *data, const git_diff_delta *delta, float progress) { diff_print_info *pi = data; const char *oldpfx = pi->diff->opts.old_prefix; @@ -1064,8 +1066,8 @@ static int print_patch_file(void *data, git_diff_delta *delta, float progress) static int print_patch_hunk( void *data, - git_diff_delta *d, - git_diff_range *r, + const git_diff_delta *d, + const git_diff_range *r, const char *header, size_t header_len) { @@ -1087,8 +1089,8 @@ static int print_patch_hunk( static int print_patch_line( void *data, - git_diff_delta *delta, - git_diff_range *range, + const git_diff_delta *delta, + const git_diff_range *range, char line_origin, /* GIT_DIFF_LINE value from above */ const char *content, size_t content_len) @@ -1158,7 +1160,7 @@ static void set_data_from_blob( int git_diff_blobs( git_blob *old_blob, git_blob *new_blob, - git_diff_options *options, + const git_diff_options *options, void *cb_data, git_diff_file_fn file_cb, git_diff_hunk_fn hunk_cb, @@ -1253,7 +1255,7 @@ size_t git_diff_num_deltas_of_type(git_diff_list *diff, git_delta_t type) int git_diff_get_patch( git_diff_patch **patch_ptr, - git_diff_delta **delta_ptr, + const git_diff_delta **delta_ptr, git_diff_list *diff, size_t idx) { @@ -1326,7 +1328,7 @@ size_t git_diff_patch_num_hunks(git_diff_patch *patch) } int git_diff_patch_get_hunk( - git_diff_range **range, + const git_diff_range **range, const char **header, size_t *header_len, size_t *lines_in_hunk, diff --git a/src/diff_output.h b/src/diff_output.h index f54639088..5fed1d998 100644 --- a/src/diff_output.h +++ b/src/diff_output.h @@ -26,7 +26,7 @@ enum { typedef struct { git_repository *repo; git_diff_list *diff; - git_diff_options *opts; + const git_diff_options *opts; git_diff_file_fn file_cb; git_diff_hunk_fn hunk_cb; git_diff_data_fn data_cb; |