From 2c65d90f7579a0e2a6460eebce44795587e87043 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Mon, 2 Sep 2019 22:39:44 +0000 Subject: am: reload .gitattributes after patching it When applying multiple patches with git am, or when rebasing using the am backend, it's possible that one of our patches has updated a gitattributes file. Currently, we cache this information, so if a file in a subsequent patch has attributes applied, the file will be written out with the attributes in place as of the time we started the rebase or am operation, not with the attributes applied by the previous patch. This problem does not occur when using the -m or -i flags to rebase. To ensure we write the correct data into the working tree, expire the cache after each patch that touches a path ending in ".gitattributes". Since we load these attributes in multiple separate files, we must expire them accordingly. Verify that both the am and rebase code paths work correctly, including the conflict marker size with am -3. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- convert.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'convert.c') diff --git a/convert.c b/convert.c index 94ff837649..deb6f71b2d 100644 --- a/convert.c +++ b/convert.c @@ -8,6 +8,7 @@ #include "pkt-line.h" #include "sub-process.h" #include "utf8.h" +#include "ll-merge.h" /* * convert.c - convert a file when checking it out and checking it in. @@ -1293,10 +1294,11 @@ struct conv_attrs { const char *working_tree_encoding; /* Supported encoding or default encoding if NULL */ }; +static struct attr_check *check; + static void convert_attrs(const struct index_state *istate, struct conv_attrs *ca, const char *path) { - static struct attr_check *check; struct attr_check_item *ccheck = NULL; if (!check) { @@ -1339,6 +1341,23 @@ static void convert_attrs(const struct index_state *istate, ca->crlf_action = CRLF_AUTO_INPUT; } +void reset_parsed_attributes(void) +{ + struct convert_driver *drv, *next; + + attr_check_free(check); + check = NULL; + reset_merge_attributes(); + + for (drv = user_convert; drv; drv = next) { + next = drv->next; + free((void *)drv->name); + free(drv); + } + user_convert = NULL; + user_convert_tail = NULL; +} + int would_convert_to_git_filter_fd(const struct index_state *istate, const char *path) { struct conv_attrs ca; -- cgit v1.2.3