| 7791 | } |
| 7792 | |
| 7793 | size_t fill_textconv(struct repository *r, |
| 7794 | struct userdiff_driver *driver, |
| 7795 | struct diff_filespec *df, |
| 7796 | char **outbuf) |
| 7797 | { |
| 7798 | size_t size; |
| 7799 | |
| 7800 | if (!driver) { |
| 7801 | if (!DIFF_FILE_VALID(df)) { |
| 7802 | *outbuf = (char *) ""; |
| 7803 | return 0; |
| 7804 | } |
| 7805 | if (diff_populate_filespec(r, df, NULL)) |
| 7806 | die("unable to read files to diff"); |
| 7807 | *outbuf = df->data; |
| 7808 | return df->size; |
| 7809 | } |
| 7810 | |
| 7811 | if (!driver->textconv) |
| 7812 | BUG("fill_textconv called with non-textconv driver"); |
| 7813 | |
| 7814 | if (driver->textconv_cache && df->oid_valid) { |
| 7815 | *outbuf = notes_cache_get(driver->textconv_cache, |
| 7816 | &df->oid, |
| 7817 | &size); |
| 7818 | if (*outbuf) |
| 7819 | return size; |
| 7820 | } |
| 7821 | |
| 7822 | *outbuf = run_textconv(r, driver->textconv, df, &size); |
| 7823 | if (!*outbuf) |
| 7824 | die("unable to read files to diff"); |
| 7825 | |
| 7826 | if (driver->textconv_cache && df->oid_valid) { |
| 7827 | /* ignore errors, as we might be in a readonly repository */ |
| 7828 | notes_cache_put(driver->textconv_cache, &df->oid, *outbuf, |
| 7829 | size); |
| 7830 | /* |
| 7831 | * we could save up changes and flush them all at the end, |
| 7832 | * but we would need an extra call after all diffing is done. |
| 7833 | * Since generating a cache entry is the slow path anyway, |
| 7834 | * this extra overhead probably isn't a big deal. |
| 7835 | */ |
| 7836 | notes_cache_write(driver->textconv_cache); |
| 7837 | } |
| 7838 | |
| 7839 | return size; |
| 7840 | } |
| 7841 | |
| 7842 | int textconv_object(struct repository *r, |
| 7843 | const char *path, |
no test coverage detected