mirror of
https://github.com/git/git.git
synced 2024-11-15 14:14:08 +01:00
Merge branch 'jk/more-comments-on-textconv' into maint
The memory ownership rule of fill_textconv() API, which was a bit tricky, has been documented a bit better. * jk/more-comments-on-textconv: diff: clarify textconv interface
This commit is contained in:
commit
aa6c22ec43
5
diff.c
5
diff.c
@ -5085,7 +5085,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
|
|||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
if (!driver || !driver->textconv) {
|
if (!driver) {
|
||||||
if (!DIFF_FILE_VALID(df)) {
|
if (!DIFF_FILE_VALID(df)) {
|
||||||
*outbuf = "";
|
*outbuf = "";
|
||||||
return 0;
|
return 0;
|
||||||
@ -5096,6 +5096,9 @@ size_t fill_textconv(struct userdiff_driver *driver,
|
|||||||
return df->size;
|
return df->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!driver->textconv)
|
||||||
|
die("BUG: fill_textconv called with non-textconv driver");
|
||||||
|
|
||||||
if (driver->textconv_cache && df->sha1_valid) {
|
if (driver->textconv_cache && df->sha1_valid) {
|
||||||
*outbuf = notes_cache_get(driver->textconv_cache, df->sha1,
|
*outbuf = notes_cache_get(driver->textconv_cache, df->sha1,
|
||||||
&size);
|
&size);
|
||||||
|
16
diff.h
16
diff.h
@ -349,10 +349,26 @@ extern void diff_no_index(struct rev_info *, int, const char **);
|
|||||||
|
|
||||||
extern int index_differs_from(const char *def, int diff_flags);
|
extern int index_differs_from(const char *def, int diff_flags);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fill the contents of the filespec "df", respecting any textconv defined by
|
||||||
|
* its userdiff driver. The "driver" parameter must come from a
|
||||||
|
* previous call to get_textconv(), and therefore should either be NULL or have
|
||||||
|
* textconv enabled.
|
||||||
|
*
|
||||||
|
* Note that the memory ownership of the resulting buffer depends on whether
|
||||||
|
* the driver field is NULL. If it is, then the memory belongs to the filespec
|
||||||
|
* struct. If it is non-NULL, then "outbuf" points to a newly allocated buffer
|
||||||
|
* that should be freed by the caller.
|
||||||
|
*/
|
||||||
extern size_t fill_textconv(struct userdiff_driver *driver,
|
extern size_t fill_textconv(struct userdiff_driver *driver,
|
||||||
struct diff_filespec *df,
|
struct diff_filespec *df,
|
||||||
char **outbuf);
|
char **outbuf);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look up the userdiff driver for the given filespec, and return it if
|
||||||
|
* and only if it has textconv enabled (otherwise return NULL). The result
|
||||||
|
* can be passed to fill_textconv().
|
||||||
|
*/
|
||||||
extern struct userdiff_driver *get_textconv(struct diff_filespec *one);
|
extern struct userdiff_driver *get_textconv(struct diff_filespec *one);
|
||||||
|
|
||||||
extern int parse_rename_score(const char **cp_p);
|
extern int parse_rename_score(const char **cp_p);
|
||||||
|
@ -23,6 +23,10 @@ int userdiff_config(const char *k, const char *v);
|
|||||||
struct userdiff_driver *userdiff_find_by_name(const char *name);
|
struct userdiff_driver *userdiff_find_by_name(const char *name);
|
||||||
struct userdiff_driver *userdiff_find_by_path(const char *path);
|
struct userdiff_driver *userdiff_find_by_path(const char *path);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize any textconv-related fields in the driver and return it, or NULL
|
||||||
|
* if it does not have textconv enabled at all.
|
||||||
|
*/
|
||||||
struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver);
|
struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver);
|
||||||
|
|
||||||
#endif /* USERDIFF */
|
#endif /* USERDIFF */
|
||||||
|
Loading…
Reference in New Issue
Block a user