Skip to content

Commit bcb5142

Browse files
committed
Merge branch 'jk/textconv-utf16' into HEAD
* jk/textconv-utf16: diff: enable autoencode by default diff: add autoencode feature diff: add utf-{16,32} binary detection diff: convert filespec is_binary flag to enum diff: respect diff_options inside get_textconv() userdiff: give textconv its own struct fill_textconv: always check DIFF_FILE_VALID()
2 parents 339e060 + 2ce119a commit bcb5142

12 files changed

Lines changed: 197 additions & 97 deletions

File tree

blame.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,9 @@ static struct commit *fake_working_tree_commit(struct repository *r,
254254

255255
switch (st.st_mode & S_IFMT) {
256256
case S_IFREG:
257-
if (opt->flags.allow_textconv &&
258-
textconv_object(r, read_from, mode, null_oid(the_hash_algo), 0, &buf_ptr, &buf_len))
257+
if (textconv_object(r, opt, read_from, mode,
258+
null_oid(the_hash_algo), 0,
259+
&buf_ptr, &buf_len))
259260
strbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1);
260261
else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
261262
die_errno("cannot open or read '%s'", read_from);
@@ -1037,8 +1038,7 @@ static void fill_origin_blob(struct diff_options *opt,
10371038
unsigned long file_size;
10381039

10391040
(*num_read_blob)++;
1040-
if (opt->flags.allow_textconv &&
1041-
textconv_object(opt->repo, o->path, o->mode,
1041+
if (textconv_object(opt->repo, opt, o->path, o->mode,
10421042
&o->blob_oid, 1, &file->ptr, &file_size))
10431043
;
10441044
else
@@ -2865,8 +2865,8 @@ void setup_scoreboard(struct blame_scoreboard *sb,
28652865
if (fill_blob_sha1_and_mode(sb->repo, o))
28662866
die(_("no such path %s in %s"), sb->path, final_commit_name);
28672867

2868-
if (sb->revs->diffopt.flags.allow_textconv &&
2869-
textconv_object(sb->repo, sb->path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
2868+
if (textconv_object(sb->repo, &sb->revs->diffopt,
2869+
sb->path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
28702870
&sb->final_buf_size))
28712871
;
28722872
else

builtin/cat-file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
174174
break;
175175

176176
case 'c':
177-
if (textconv_object(the_repository, path, obj_context.mode,
178-
&oid, 1, &buf, &size))
177+
if (textconv_object(the_repository, NULL, path,
178+
obj_context.mode, &oid, 1, &buf, &size))
179179
break;
180180
/* else fallthrough */
181181

@@ -407,7 +407,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
407407
oid_to_hex(oid), data->rest);
408408
} else if (opt->transform_mode == 'c') {
409409
enum object_type type;
410-
if (!textconv_object(the_repository,
410+
if (!textconv_object(the_repository, NULL,
411411
data->rest, 0100644, oid,
412412
1, &contents, &size))
413413
contents = odb_read_object(the_repository->objects,

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
605605
&oidc, &obj_context))
606606
die(_("not a valid object name %s"), obj_name);
607607
if (!obj_context.path ||
608-
!textconv_object(the_repository, obj_context.path,
608+
!textconv_object(the_repository, NULL, obj_context.path,
609609
obj_context.mode, &oidc, 1, &buf, &size)) {
610610
object_context_release(&obj_context);
611611
return odb_stream_blob_to_fd(the_repository->objects, 1, oid, NULL, 0);

combine-diff.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,
304304

305305
static char *grab_blob(struct repository *r,
306306
const struct object_id *oid, unsigned int mode,
307-
unsigned long *size, struct userdiff_driver *textconv,
307+
unsigned long *size, struct userdiff_textconv *textconv,
308308
const char *path)
309309
{
310310
char *blob;
@@ -420,7 +420,7 @@ static void combine_diff(struct repository *r,
420420
mmfile_t *result_file,
421421
struct sline *sline, unsigned int cnt, int n,
422422
int num_parent, int result_deleted,
423-
struct userdiff_driver *textconv,
423+
struct userdiff_textconv *textconv,
424424
const char *path, long flags)
425425
{
426426
unsigned int p_lno, lno;
@@ -1021,7 +1021,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
10211021
int i, show_hunks;
10221022
mmfile_t result_file;
10231023
struct userdiff_driver *userdiff;
1024-
struct userdiff_driver *textconv = NULL;
1024+
struct userdiff_textconv *textconv = NULL;
10251025
int is_binary;
10261026
const char *line_prefix = diff_line_prefix(opt);
10271027

0 commit comments

Comments
 (0)