| 43 | |
| 44 | |
| 45 | void probe_utf8_pathname_composition(void) |
| 46 | { |
| 47 | struct strbuf path = STRBUF_INIT; |
| 48 | static const char *auml_nfc = "\xc3\xa4"; |
| 49 | static const char *auml_nfd = "\x61\xcc\x88"; |
| 50 | int output_fd; |
| 51 | struct repo_config_values *cfg = repo_config_values(the_repository); |
| 52 | |
| 53 | if (cfg->precomposed_unicode != -1) |
| 54 | return; /* We found it defined in the global config, respect it */ |
| 55 | repo_git_path_replace(the_repository, &path, "%s", auml_nfc); |
| 56 | output_fd = open(path.buf, O_CREAT|O_EXCL|O_RDWR, 0600); |
| 57 | if (output_fd >= 0) { |
| 58 | close(output_fd); |
| 59 | repo_git_path_replace(the_repository, &path, "%s", auml_nfd); |
| 60 | cfg->precomposed_unicode = access(path.buf, R_OK) ? 0 : 1; |
| 61 | repo_config_set(the_repository, "core.precomposeunicode", |
| 62 | cfg->precomposed_unicode ? "true" : "false"); |
| 63 | repo_git_path_replace(the_repository, &path, "%s", auml_nfc); |
| 64 | if (unlink(path.buf)) |
| 65 | die_errno(_("failed to unlink '%s'"), path.buf); |
| 66 | } |
| 67 | strbuf_release(&path); |
| 68 | } |
| 69 | |
| 70 | const char *precompose_string_if_needed(const char *in) |
| 71 | { |
no test coverage detected