| 476 | } |
| 477 | |
| 478 | static int encode_to_worktree(const char *path, const char *src, size_t src_len, |
| 479 | struct strbuf *buf, const char *enc) |
| 480 | { |
| 481 | char *dst; |
| 482 | size_t dst_len; |
| 483 | |
| 484 | /* |
| 485 | * No encoding is specified or there is nothing to encode. |
| 486 | * Tell the caller that the content was not modified. |
| 487 | */ |
| 488 | if (!enc || (src && !src_len)) |
| 489 | return 0; |
| 490 | |
| 491 | dst = reencode_string_len(src, src_len, enc, default_encoding, |
| 492 | &dst_len); |
| 493 | if (!dst) { |
| 494 | error(_("failed to encode '%s' from %s to %s"), |
| 495 | path, default_encoding, enc); |
| 496 | return 0; |
| 497 | } |
| 498 | |
| 499 | strbuf_attach(buf, dst, dst_len, dst_len + 1); |
| 500 | return 1; |
| 501 | } |
| 502 | |
| 503 | static int crlf_to_git(struct index_state *istate, |
| 504 | const char *path, const char *src, size_t len, |
no test coverage detected