From a5a386436b823257b9e1b1365d3e36c00a1a5d89 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 20 Jan 2014 14:53:59 -0800 Subject: [PATCH 01/12] Initial take on builtin drivers with multiline This extends the diff driver parser to support multiline driver definitions along with ! prefixing for negated matches. This brings the driver function pattern parsing in line with core Git. This also adds an internal table of driver definitions and a fallback code path that will look in that table for diff drivers that are set with attributes without having a definition in the config file. Right now, I just populated the table with a kind of simple HTML definition that is similar to the core Git def. --- src/diff_driver.c | 181 +++++++++++++++++++++++++++++++++++----------- src/diff_driver.h | 2 +- 2 files changed, 140 insertions(+), 43 deletions(-) diff --git a/src/diff_driver.c b/src/diff_driver.c index 167c0cc5a..dcd74adf0 100644 --- a/src/diff_driver.c +++ b/src/diff_driver.c @@ -26,10 +26,13 @@ typedef enum { DIFF_DRIVER_PATTERNLIST = 3, } git_diff_driver_t; +typedef struct { + regex_t re; + int flags; +} git_diff_driver_pattern; + enum { - DIFF_CONTEXT_FIND_NORMAL = 0, - DIFF_CONTEXT_FIND_ICASE = (1 << 0), - DIFF_CONTEXT_FIND_EXT = (1 << 1), + REG_NEGATE = (1 << 15) /* get out of the way of existing flags */ }; /* data for finding function context for a given file type */ @@ -37,11 +40,22 @@ struct git_diff_driver { git_diff_driver_t type; uint32_t binary_flags; uint32_t other_flags; - git_array_t(regex_t) fn_patterns; + git_array_t(git_diff_driver_pattern) fn_patterns; regex_t word_pattern; char name[GIT_FLEX_ARRAY]; }; +typedef struct { + const char *name; + const char *fns; + const char *words; + int flags; +} git_diff_driver_definition; + +static git_diff_driver_definition builtin_defs[] = { + { "html", "^[ \t]*(]*)?>.*)$", "[^<> \t]+", REG_ICASE }, +}; + struct git_diff_driver_registry { git_strmap *drivers; }; @@ -81,34 +95,59 @@ void git_diff_driver_registry_free(git_diff_driver_registry *reg) git__free(reg); } -static int diff_driver_add_funcname( - git_diff_driver *drv, const char *name, int regex_flags) +static int diff_driver_add_patterns( + git_diff_driver *drv, const char *regex_str, int regex_flags) { - int error; - regex_t re, *re_ptr; + int error = 0; + const char *scan, *end; + git_diff_driver_pattern *pat = NULL; + git_buf buf = GIT_BUF_INIT; - if ((error = regcomp(&re, name, regex_flags)) != 0) { - /* TODO: warning about bad regex instead of failure */ - error = giterr_set_regex(&re, error); - regfree(&re); - return error; + for (scan = regex_str; scan; scan = end) { + /* get pattern to fill in */ + if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) { + error = -1; + break; + } + + pat->flags = regex_flags; + if (*scan == '!') { + pat->flags |= REG_NEGATE; + ++scan; + } + + if ((end = strchr(scan, '\n')) != NULL) { + error = git_buf_set(&buf, scan, end - scan); + end++; + } else { + error = git_buf_sets(&buf, scan); + } + if (error < 0) + break; + + if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) < 0) { + /* if regex fails to compile, warn? fail? */ + error = giterr_set_regex(&pat->re, error); + regfree(&pat->re); + break; + } } - re_ptr = git_array_alloc(drv->fn_patterns); - GITERR_CHECK_ALLOC(re_ptr); + if (error && pat != NULL) + (void)git_array_pop(drv->fn_patterns); /* release last item */ + git_buf_free(&buf); - memcpy(re_ptr, &re, sizeof(re)); - return 0; + return error; } static int diff_driver_xfuncname(const git_config_entry *entry, void *payload) { - return diff_driver_add_funcname(payload, entry->value, REG_EXTENDED); + return diff_driver_add_patterns(payload, entry->value, REG_EXTENDED); } static int diff_driver_funcname(const git_config_entry *entry, void *payload) { - return diff_driver_add_funcname(payload, entry->value, 0); + return diff_driver_add_patterns(payload, entry->value, 0); } static git_diff_driver_registry *git_repository_driver_registry( @@ -128,12 +167,65 @@ static git_diff_driver_registry *git_repository_driver_registry( return repo->diff_drivers; } +static int git_diff_driver_builtin( + git_diff_driver **out, + git_diff_driver_registry *reg, + const char *driver_name) +{ + int error = 0; + git_diff_driver_definition *ddef = NULL; + git_diff_driver *drv = NULL; + size_t namelen, idx; + + for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) { + if (!strcasecmp(driver_name, builtin_defs[idx].name)) { + ddef = &builtin_defs[idx]; + break; + } + } + if (!ddef) + goto done; + + namelen = strlen(ddef->name); + + drv = git__calloc(1, sizeof(git_diff_driver) + namelen + 1); + GITERR_CHECK_ALLOC(drv); + + drv->type = DIFF_DRIVER_PATTERNLIST; + memcpy(drv->name, ddef->name, namelen); + + if (ddef->fns && + (error = diff_driver_add_patterns( + drv, ddef->fns, ddef->flags | REG_EXTENDED)) < 0) + goto done; + + if (ddef->words && + (error = regcomp( + &drv->word_pattern, ddef->words, ddef->flags | REG_EXTENDED))) + { + error = giterr_set_regex(&drv->word_pattern, error); + goto done; + } + + git_strmap_insert(reg->drivers, drv->name, drv, error); + +done: + if (error || !drv) { + git_diff_driver_free(drv); + *out = &global_drivers[DIFF_DRIVER_AUTO]; + } else { + *out = drv; + } + + return error; +} + static int git_diff_driver_load( git_diff_driver **out, git_repository *repo, const char *driver_name) { int error = 0; git_diff_driver_registry *reg; - git_diff_driver *drv; + git_diff_driver *drv = NULL; size_t namelen = strlen(driver_name); khiter_t pos; git_config *cfg; @@ -141,21 +233,19 @@ static int git_diff_driver_load( const git_config_entry *ce; bool found_driver = false; - reg = git_repository_driver_registry(repo); - if (!reg) + if ((reg = git_repository_driver_registry(repo)) == NULL) return -1; - else { - pos = git_strmap_lookup_index(reg->drivers, driver_name); - if (git_strmap_valid_index(reg->drivers, pos)) { - *out = git_strmap_value_at(reg->drivers, pos); - return 0; - } + + pos = git_strmap_lookup_index(reg->drivers, driver_name); + if (git_strmap_valid_index(reg->drivers, pos)) { + *out = git_strmap_value_at(reg->drivers, pos); + return 0; } /* if you can't read config for repo, just use default driver */ if (git_repository_config__weakptr(&cfg, repo) < 0) { giterr_clear(); - return GIT_ENOTFOUND; + goto done; } drv = git__calloc(1, sizeof(git_diff_driver) + namelen + 1); @@ -178,7 +268,7 @@ static int git_diff_driver_load( found_driver = true; break; default: - /* diff..binary unspecified, so just continue */ + /* diff..binary unspecified or "auto", so just continue */ break; } @@ -240,8 +330,11 @@ static int git_diff_driver_load( done: git_buf_free(&name); - if (!*out) - *out = &global_drivers[DIFF_DRIVER_AUTO]; + if (!*out) { + int error2 = git_diff_driver_builtin(out, reg, driver_name); + if (!error) + error = error2; + } if (drv && drv != *out) git_diff_driver_free(drv); @@ -293,7 +386,7 @@ void git_diff_driver_free(git_diff_driver *driver) return; for (i = 0; i < git_array_size(driver->fn_patterns); ++i) - regfree(git_array_get(driver->fn_patterns, i)); + regfree(& git_array_get(driver->fn_patterns, i)->re); git_array_clear(driver->fn_patterns); regfree(&driver->word_pattern); @@ -330,23 +423,28 @@ int git_diff_driver_content_is_binary( } static int diff_context_line__simple( - git_diff_driver *driver, const char *line, size_t line_len) + git_diff_driver *driver, git_buf *line) { + char firstch = line->ptr[0]; GIT_UNUSED(driver); - GIT_UNUSED(line_len); - return (git__isalpha(*line) || *line == '_' || *line == '$'); + return (git__isalpha(firstch) || firstch == '_' || firstch == '$'); } static int diff_context_line__pattern_match( - git_diff_driver *driver, const char *line, size_t line_len) + git_diff_driver *driver, git_buf *line) { size_t i; - - GIT_UNUSED(line_len); + regmatch_t pmatch[2]; for (i = 0; i < git_array_size(driver->fn_patterns); ++i) { - if (!regexec(git_array_get(driver->fn_patterns, i), line, 0, NULL, 0)) + git_diff_driver_pattern *pat = git_array_get(driver->fn_patterns, i); + + if (!regexec(&pat->re, line->ptr, 2, pmatch, 0)) { + if (pat->flags & REG_NEGATE) + return false; + /* TODO: use pmatch data to trim line data */ return true; + } } return false; @@ -368,8 +466,7 @@ static long diff_context_find( if (!ctxt->line.size) return -1; - if (!ctxt->match_line || - !ctxt->match_line(ctxt->driver, ctxt->line.ptr, ctxt->line.size)) + if (!ctxt->match_line || !ctxt->match_line(ctxt->driver, &ctxt->line)) return -1; if (out_size > (long)ctxt->line.size) diff --git a/src/diff_driver.h b/src/diff_driver.h index 9d3f18660..0706dcfc5 100644 --- a/src/diff_driver.h +++ b/src/diff_driver.h @@ -31,7 +31,7 @@ typedef long (*git_diff_find_context_fn)( const char *, long, char *, long, void *); typedef int (*git_diff_find_context_line)( - git_diff_driver *, const char *, size_t); + git_diff_driver *, git_buf *); typedef struct { git_diff_driver *driver; From 2c65602e45964f695bda91a6b1cfbf6b2f4903ea Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 21 Jan 2014 10:39:27 -0800 Subject: [PATCH 02/12] Import git drivers and test HTML driver Reorganize the builtin driver table slightly so that core Git builtin definitions can be imported verbatim. Then take a few of the core Git drivers and pull them in. This also creates a test of diffs with the builtin HTML driver which led to some small error handling fixes in the driver selection logic. --- src/diff_driver.c | 59 +++++++++++++++------ tests/diff/drivers.c | 123 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 142 insertions(+), 40 deletions(-) diff --git a/src/diff_driver.c b/src/diff_driver.c index dcd74adf0..169f7b025 100644 --- a/src/diff_driver.c +++ b/src/diff_driver.c @@ -52,10 +52,38 @@ typedef struct { int flags; } git_diff_driver_definition; +#define WORD_DEFAULT "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" + +/* builtin driver definition macros have same signature as in core git + * userdiff.c so that the data can be extracted verbatim + */ +#define PATTERNS(NAME, FN_PATS, WORD_PAT) \ + { NAME, FN_PATS, WORD_PAT WORD_DEFAULT, 0 } +#define IPATTERN(NAME, FN_PATS, WORD_PAT) \ + { NAME, FN_PATS, WORD_PAT WORD_DEFAULT, REG_ICASE } + static git_diff_driver_definition builtin_defs[] = { - { "html", "^[ \t]*(]*)?>.*)$", "[^<> \t]+", REG_ICASE }, +PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$", + "[^<>= \t]+"), +PATTERNS("java", + "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n" + "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=" + "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$", + /* -- */ + "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." + "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), }; +#undef IPATTERN +#undef PATTERNS +#undef WORD_DEFAULT + struct git_diff_driver_registry { git_strmap *drivers; }; @@ -208,14 +236,14 @@ static int git_diff_driver_builtin( } git_strmap_insert(reg->drivers, drv->name, drv, error); + if (error > 0) + error = 0; done: - if (error || !drv) { + if (error && drv) git_diff_driver_free(drv); - *out = &global_drivers[DIFF_DRIVER_AUTO]; - } else { + else *out = drv; - } return error; } @@ -324,6 +352,7 @@ static int git_diff_driver_load( git_strmap_insert(reg->drivers, drv->name, drv, error); if (error < 0) goto done; + error = 0; *out = drv; @@ -349,14 +378,13 @@ int git_diff_driver_lookup( const char *value; assert(out); + *out = NULL; if (!repo || !path || !strlen(path)) - goto use_auto; - - if ((error = git_attr_get(&value, repo, 0, path, "diff")) < 0) - return error; - - if (GIT_ATTR_UNSPECIFIED(value)) + /* just use the auto value */; + else if ((error = git_attr_get(&value, repo, 0, path, "diff")) < 0) + /* return error below */; + else if (GIT_ATTR_UNSPECIFIED(value)) /* just use the auto value */; else if (GIT_ATTR_FALSE(value)) *out = &global_drivers[DIFF_DRIVER_BINARY]; @@ -365,17 +393,16 @@ int git_diff_driver_lookup( /* otherwise look for driver information in config and build driver */ else if ((error = git_diff_driver_load(out, repo, value)) < 0) { - if (error != GIT_ENOTFOUND) - return error; - else + if (error == GIT_ENOTFOUND) { + error = 0; giterr_clear(); + } } -use_auto: if (!*out) *out = &global_drivers[DIFF_DRIVER_AUTO]; - return 0; + return error; } void git_diff_driver_free(git_diff_driver *driver) diff --git a/tests/diff/drivers.c b/tests/diff/drivers.c index c80fad4c2..4524cd0db 100644 --- a/tests/diff/drivers.c +++ b/tests/diff/drivers.c @@ -15,6 +15,15 @@ void test_diff_drivers__cleanup(void) g_repo = NULL; } +static void overwrite_chmod_at_offset(git_buf *buf, size_t offset) +{ + if (cl_is_chmod_supported()) + return; + + if (buf->size > offset + 6 && memcmp(&buf->ptr[offset], "100644", 6) != 0) + memcpy(&buf->ptr[offset], "100644", 6); +} + void test_diff_drivers__patterns(void) { git_config *cfg; @@ -22,7 +31,7 @@ void test_diff_drivers__patterns(void) git_tree *one; git_diff *diff; git_patch *patch; - git_buf buf = GIT_BUF_INIT; + git_buf actual = GIT_BUF_INIT; const char *expected0 = "diff --git a/untimely.txt b/untimely.txt\nindex 9a69d96..57fd0cf 100644\n--- a/untimely.txt\n+++ b/untimely.txt\n@@ -22,3 +22,5 @@ Comes through the blood of the vanguards who\n dreamed--too soon--it had sounded.\r\n \r\n -- Rudyard Kipling\r\n+\r\n+Some new stuff\r\n"; const char *expected1 = "diff --git a/untimely.txt b/untimely.txt\nindex 9a69d96..57fd0cf 100644\nBinary files a/untimely.txt and b/untimely.txt differ\n"; const char *expected2 = "diff --git a/untimely.txt b/untimely.txt\nindex 9a69d96..57fd0cf 100644\n--- a/untimely.txt\n+++ b/untimely.txt\n@@ -22,3 +22,5 @@ Heaven delivers on earth the Hour that cannot be\n dreamed--too soon--it had sounded.\r\n \r\n -- Rudyard Kipling\r\n+\r\n+Some new stuff\r\n"; @@ -45,10 +54,10 @@ void test_diff_drivers__patterns(void) cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); cl_git_pass(git_patch_from_diff(&patch, diff, 0)); - cl_git_pass(git_patch_to_buf(&buf, patch)); - cl_assert_equal_s(expected0, buf.ptr); + cl_git_pass(git_patch_to_buf(&actual, patch)); + cl_assert_equal_s(expected0, actual.ptr); - git_buf_free(&buf); + git_buf_free(&actual); git_patch_free(patch); git_diff_free(diff); @@ -60,10 +69,10 @@ void test_diff_drivers__patterns(void) cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); cl_git_pass(git_patch_from_diff(&patch, diff, 0)); - cl_git_pass(git_patch_to_buf(&buf, patch)); - cl_assert_equal_s(expected1, buf.ptr); + cl_git_pass(git_patch_to_buf(&actual, patch)); + cl_assert_equal_s(expected1, actual.ptr); - git_buf_free(&buf); + git_buf_free(&actual); git_patch_free(patch); git_diff_free(diff); @@ -75,10 +84,10 @@ void test_diff_drivers__patterns(void) cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); cl_git_pass(git_patch_from_diff(&patch, diff, 0)); - cl_git_pass(git_patch_to_buf(&buf, patch)); - cl_assert_equal_s(expected0, buf.ptr); + cl_git_pass(git_patch_to_buf(&actual, patch)); + cl_assert_equal_s(expected0, actual.ptr); - git_buf_free(&buf); + git_buf_free(&actual); git_patch_free(patch); git_diff_free(diff); @@ -92,10 +101,10 @@ void test_diff_drivers__patterns(void) cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); cl_git_pass(git_patch_from_diff(&patch, diff, 0)); - cl_git_pass(git_patch_to_buf(&buf, patch)); - cl_assert_equal_s(expected1, buf.ptr); + cl_git_pass(git_patch_to_buf(&actual, patch)); + cl_assert_equal_s(expected1, actual.ptr); - git_buf_free(&buf); + git_buf_free(&actual); git_patch_free(patch); git_diff_free(diff); @@ -113,10 +122,10 @@ void test_diff_drivers__patterns(void) cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); cl_git_pass(git_patch_from_diff(&patch, diff, 0)); - cl_git_pass(git_patch_to_buf(&buf, patch)); - cl_assert_equal_s(expected2, buf.ptr); + cl_git_pass(git_patch_to_buf(&actual, patch)); + cl_assert_equal_s(expected2, actual.ptr); - git_buf_free(&buf); + git_buf_free(&actual); git_patch_free(patch); git_diff_free(diff); @@ -129,7 +138,7 @@ void test_diff_drivers__long_lines(void) git_index *idx; git_diff *diff; git_patch *patch; - git_buf buf = GIT_BUF_INIT; + git_buf actual = GIT_BUF_INIT; const char *expected = "diff --git a/longlines.txt b/longlines.txt\nindex c1ce6ef..0134431 100644\n--- a/longlines.txt\n+++ b/longlines.txt\n@@ -3,3 +3,5 @@ Phasellus eget erat odio. Praesent at est iaculis, ultricies augue vel, dignissi\n Nam eget dolor fermentum, aliquet nisl at, convallis tellus. Pellentesque rhoncus erat enim, id porttitor elit euismod quis.\n Mauris sollicitudin magna odio, non egestas libero vehicula ut. Etiam et quam velit. Fusce eget libero rhoncus, ultricies felis sit amet, egestas purus.\n Aliquam in semper tellus. Pellentesque adipiscing rutrum velit, quis malesuada lacus consequat eget.\n+newline\n+newline\n"; g_repo = cl_git_sandbox_init("empty_standard_repo"); @@ -145,18 +154,84 @@ void test_diff_drivers__long_lines(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, NULL)); cl_assert_equal_sz(1, git_diff_num_deltas(diff)); cl_git_pass(git_patch_from_diff(&patch, diff, 0)); - cl_git_pass(git_patch_to_buf(&buf, patch)); + cl_git_pass(git_patch_to_buf(&actual, patch)); /* if chmod not supported, overwrite mode bits since anything is possible */ - if (!cl_is_chmod_supported()) { - if (buf.size > 72 && memcmp(&buf.ptr[66], "100644", 6) != 0) - memcpy(&buf.ptr[66], "100644", 6); - } + overwrite_chmod_at_offset(&actual, 66); - cl_assert_equal_s(expected, buf.ptr); + cl_assert_equal_s(expected, actual.ptr); - git_buf_free(&buf); + git_buf_free(&actual); git_patch_free(patch); git_diff_free(diff); } +void test_diff_drivers__builtins(void) +{ + git_index *idx; + git_diff *diff; + git_patch *patch; + git_buf actual = GIT_BUF_INIT; + git_diff_options opts = GIT_DIFF_OPTIONS_INIT; + const char *base = + "\n\n" + "

\n
    \n
  1. item 1.1
  2. \n
  3. item 1.2
  4. \n
  5. item 1.3
  6. \n
  7. item 1.4
  8. \n
  9. item 1.5
  10. \n
  11. item 1.6
  12. \n
  13. item 1.7
  14. \n
  15. item 1.8
  16. \n
  17. item 1.9
  18. \n
\n

\n" + "

\n
    \n
  1. item 2.1
  2. \n
  3. item 2.2
  4. \n
  5. item 2.3
  6. \n
  7. item 2.4
  8. \n
  9. item 2.5
  10. \n
  11. item 2.6
  12. \n
  13. item 2.7
  14. \n
  15. item 2.8
  16. \n
\n

\n" + "

\n
    \n
  1. item 3.1
  2. \n
  3. item 3.2
  4. \n
  5. item 3.3
  6. \n
  7. item 3.4
  8. \n
  9. item 3.5
  10. \n
  11. item 3.6
  12. \n
  13. item 3.7
  14. \n
  15. item 3.8
  16. \n
\n

\n" + "\n"; + const char *modified = + "\n\n" + "

\n
    \n
  1. item 1.1
  2. \n
  3. item 1.2 changed
  4. \n
  5. item 1.3 changed
  6. \n
  7. item 1.4
  8. \n
  9. item 1.5
  10. \n
  11. item 1.6
  12. \n
  13. item 1.7
  14. \n
  15. item 1.8
  16. \n
  17. item 1.9
  18. \n
  19. item 1.10 added
  20. \n
\n

\n" + "

\n
    \n
  1. item 2.1
  2. \n
  3. item 2.2
  4. \n
  5. item 2.3
  6. \n
  7. item 2.4
  8. \n
  9. item 2.5
  10. \n
  11. item 2.6
  12. \n
  13. item 2.7 changed
  14. \n
  15. item 2.7.1 added
  16. \n
  17. item 2.8
  18. \n
\n

\n" + "

\n
    \n
  1. item 3.1
  2. \n
  3. item 3.2
  4. \n
  5. item 3.3
  6. \n
  7. item 3.4
  8. \n
  9. item 3.5
  10. \n
  11. item 3.6
  12. \n
\n

\n" + "\n"; + const char *expected_nodriver = + "diff --git a/file.html b/file.html\nindex 97b34db..c7dbed3 100644\n--- a/file.html\n+++ b/file.html\n@@ -5,4 +5,4 @@\n
  • item 1.1
  • \n-
  • item 1.2
  • \n-
  • item 1.3
  • \n+
  • item 1.2 changed
  • \n+
  • item 1.3 changed
  • \n
  • item 1.4
  • \n@@ -13,2 +13,3 @@\n
  • item 1.9
  • \n+
  • item 1.10 added
  • \n \n@@ -23,3 +24,4 @@\n
  • item 2.6
  • \n-
  • item 2.7
  • \n+
  • item 2.7 changed
  • \n+
  • item 2.7.1 added
  • \n
  • item 2.8
  • \n@@ -35,4 +37,2 @@\n
  • item 3.6
  • \n-
  • item 3.7
  • \n-
  • item 3.8
  • \n \n"; + const char *expected_driver = + "diff --git a/file.html b/file.html\nindex 97b34db..c7dbed3 100644\n--- a/file.html\n+++ b/file.html\n@@ -5,4 +5,4 @@

    \n
  • item 1.1
  • \n-
  • item 1.2
  • \n-
  • item 1.3
  • \n+
  • item 1.2 changed
  • \n+
  • item 1.3 changed
  • \n
  • item 1.4
  • \n@@ -13,2 +13,3 @@

    \n
  • item 1.9
  • \n+
  • item 1.10 added
  • \n \n@@ -23,3 +24,4 @@

    \n
  • item 2.6
  • \n-
  • item 2.7
  • \n+
  • item 2.7 changed
  • \n+
  • item 2.7.1 added
  • \n
  • item 2.8
  • \n@@ -35,4 +37,2 @@

    \n
  • item 3.6
  • \n-
  • item 3.7
  • \n-
  • item 3.8
  • \n \n"; + + g_repo = cl_git_sandbox_init("empty_standard_repo"); + + cl_git_mkfile("empty_standard_repo/file.html", base); + cl_git_pass(git_repository_index(&idx, g_repo)); + cl_git_pass(git_index_add_bypath(idx, "file.html")); + cl_git_pass(git_index_write(idx)); + git_index_free(idx); + + cl_git_rewritefile("empty_standard_repo/file.html", modified); + + /* do diff with no special driver */ + + opts.interhunk_lines = 1; + opts.context_lines = 1; + + cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); + cl_assert_equal_sz(1, git_diff_num_deltas(diff)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); + cl_git_pass(git_patch_to_buf(&actual, patch)); + + overwrite_chmod_at_offset(&actual, 59); + + cl_assert_equal_s(expected_nodriver, actual.ptr); + + git_buf_free(&actual); + git_patch_free(patch); + git_diff_free(diff); + + /* do diff with HTML driver */ + + cl_git_mkfile("empty_standard_repo/.gitattributes", "*.html diff=html\n"); + + cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); + cl_assert_equal_sz(1, git_diff_num_deltas(diff)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); + cl_git_pass(git_patch_to_buf(&actual, patch)); + + overwrite_chmod_at_offset(&actual, 59); + + cl_assert_equal_s(expected_driver, actual.ptr); + + git_buf_free(&actual); + git_patch_free(patch); + git_diff_free(diff); +} From 9bbc53d6d424cbdc8b5ca47f6a85b49794c516fe Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 21 Jan 2014 11:36:43 -0800 Subject: [PATCH 03/12] Fix filemode updating in diff text --- tests/diff/drivers.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/diff/drivers.c b/tests/diff/drivers.c index 4524cd0db..003a84485 100644 --- a/tests/diff/drivers.c +++ b/tests/diff/drivers.c @@ -15,13 +15,21 @@ void test_diff_drivers__cleanup(void) g_repo = NULL; } -static void overwrite_chmod_at_offset(git_buf *buf, size_t offset) +static void overwrite_filemode(const char *expected, git_buf *actual) { - if (cl_is_chmod_supported()) + size_t offset; + char *found; + + found = strstr(expected, "100644"); + if (!found) return; - if (buf->size > offset + 6 && memcmp(&buf->ptr[offset], "100644", 6) != 0) - memcpy(&buf->ptr[offset], "100644", 6); + offset = ((const char *)found) - expected; + if (actual->size < offset + 6) + return; + + if (memcmp(&actual->ptr[offset], "100644", 6) != 0) + memcpy(&actual->ptr[offset], "100644", 6); } void test_diff_drivers__patterns(void) @@ -157,7 +165,7 @@ void test_diff_drivers__long_lines(void) cl_git_pass(git_patch_to_buf(&actual, patch)); /* if chmod not supported, overwrite mode bits since anything is possible */ - overwrite_chmod_at_offset(&actual, 66); + overwrite_filemode(expected, &actual); cl_assert_equal_s(expected, actual.ptr); @@ -210,7 +218,7 @@ void test_diff_drivers__builtins(void) cl_git_pass(git_patch_from_diff(&patch, diff, 0)); cl_git_pass(git_patch_to_buf(&actual, patch)); - overwrite_chmod_at_offset(&actual, 59); + overwrite_filemode(expected_nodriver, &actual); cl_assert_equal_s(expected_nodriver, actual.ptr); @@ -227,7 +235,7 @@ void test_diff_drivers__builtins(void) cl_git_pass(git_patch_from_diff(&patch, diff, 0)); cl_git_pass(git_patch_to_buf(&actual, patch)); - overwrite_chmod_at_offset(&actual, 59); + overwrite_filemode(expected_driver, &actual); cl_assert_equal_s(expected_driver, actual.ptr); From b8e86c62f7512425e29f340a38152978d869e316 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 21 Jan 2014 12:00:08 -0800 Subject: [PATCH 04/12] Implement matched pattern extract for fn headers --- src/diff_driver.c | 11 ++++++++--- tests/diff/drivers.c | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/diff_driver.c b/src/diff_driver.c index 169f7b025..56b5b5a51 100644 --- a/src/diff_driver.c +++ b/src/diff_driver.c @@ -460,16 +460,21 @@ static int diff_context_line__simple( static int diff_context_line__pattern_match( git_diff_driver *driver, git_buf *line) { - size_t i; + size_t i, maxi = git_array_size(driver->fn_patterns); regmatch_t pmatch[2]; - for (i = 0; i < git_array_size(driver->fn_patterns); ++i) { + for (i = 0; i < maxi; ++i) { git_diff_driver_pattern *pat = git_array_get(driver->fn_patterns, i); if (!regexec(&pat->re, line->ptr, 2, pmatch, 0)) { if (pat->flags & REG_NEGATE) return false; - /* TODO: use pmatch data to trim line data */ + + /* use pmatch data to trim line data */ + i = (pmatch[1].rm_so >= 0) ? 1 : 0; + git_buf_consume(line, git_buf_cstr(line) + pmatch[i].rm_so); + git_buf_truncate(line, pmatch[i].rm_eo - pmatch[i].rm_so); + return true; } } diff --git a/tests/diff/drivers.c b/tests/diff/drivers.c index 003a84485..119132149 100644 --- a/tests/diff/drivers.c +++ b/tests/diff/drivers.c @@ -123,7 +123,7 @@ void test_diff_drivers__patterns(void) cl_git_pass(git_repository_config(&cfg, g_repo)); cl_git_pass(git_config_set_bool(cfg, "diff.kipling0.binary", 0)); - cl_git_pass(git_config_set_string(cfg, "diff.kipling0.xfuncname", "^H")); + cl_git_pass(git_config_set_string(cfg, "diff.kipling0.xfuncname", "^H.*$")); git_config_free(cfg); cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, one, NULL)); @@ -196,7 +196,7 @@ void test_diff_drivers__builtins(void) const char *expected_nodriver = "diff --git a/file.html b/file.html\nindex 97b34db..c7dbed3 100644\n--- a/file.html\n+++ b/file.html\n@@ -5,4 +5,4 @@\n
  • item 1.1
  • \n-
  • item 1.2
  • \n-
  • item 1.3
  • \n+
  • item 1.2 changed
  • \n+
  • item 1.3 changed
  • \n
  • item 1.4
  • \n@@ -13,2 +13,3 @@\n
  • item 1.9
  • \n+
  • item 1.10 added
  • \n \n@@ -23,3 +24,4 @@\n
  • item 2.6
  • \n-
  • item 2.7
  • \n+
  • item 2.7 changed
  • \n+
  • item 2.7.1 added
  • \n
  • item 2.8
  • \n@@ -35,4 +37,2 @@\n
  • item 3.6
  • \n-
  • item 3.7
  • \n-
  • item 3.8
  • \n \n"; const char *expected_driver = - "diff --git a/file.html b/file.html\nindex 97b34db..c7dbed3 100644\n--- a/file.html\n+++ b/file.html\n@@ -5,4 +5,4 @@

    \n
  • item 1.1
  • \n-
  • item 1.2
  • \n-
  • item 1.3
  • \n+
  • item 1.2 changed
  • \n+
  • item 1.3 changed
  • \n
  • item 1.4
  • \n@@ -13,2 +13,3 @@

    \n
  • item 1.9
  • \n+
  • item 1.10 added
  • \n \n@@ -23,3 +24,4 @@

    \n
  • item 2.6
  • \n-
  • item 2.7
  • \n+
  • item 2.7 changed
  • \n+
  • item 2.7.1 added
  • \n
  • item 2.8
  • \n@@ -35,4 +37,2 @@

    \n
  • item 3.6
  • \n-
  • item 3.7
  • \n-
  • item 3.8
  • \n \n"; + "diff --git a/file.html b/file.html\nindex 97b34db..c7dbed3 100644\n--- a/file.html\n+++ b/file.html\n@@ -5,4 +5,4 @@

    \n
  • item 1.1
  • \n-
  • item 1.2
  • \n-
  • item 1.3
  • \n+
  • item 1.2 changed
  • \n+
  • item 1.3 changed
  • \n
  • item 1.4
  • \n@@ -13,2 +13,3 @@

    \n
  • item 1.9
  • \n+
  • item 1.10 added
  • \n \n@@ -23,3 +24,4 @@

    \n
  • item 2.6
  • \n-
  • item 2.7
  • \n+
  • item 2.7 changed
  • \n+
  • item 2.7.1 added
  • \n
  • item 2.8
  • \n@@ -35,4 +37,2 @@

    \n
  • item 3.6
  • \n-
  • item 3.7
  • \n-
  • item 3.8
  • \n \n"; g_repo = cl_git_sandbox_init("empty_standard_repo"); From 5d82c0df13ad3bd8edf85ba8d5f3796e93f926d8 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 21 Jan 2014 12:08:02 -0800 Subject: [PATCH 05/12] Update all tests for new pattern extraction --- tests/diff/blob.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/diff/blob.c b/tests/diff/blob.c index 63e3c5b7d..843937728 100644 --- a/tests/diff/blob.c +++ b/tests/diff/blob.c @@ -861,15 +861,15 @@ void test_diff_blob__using_path_and_attributes(void) cl_git_pass(git_config_set_bool(cfg, "diff.iam_binary.binary", 1)); cl_git_pass(git_config_set_bool(cfg, "diff.iam_text.binary", 0)); cl_git_pass(git_config_set_string( - cfg, "diff.iam_alphactx.xfuncname", "^[A-Za-z]")); + cfg, "diff.iam_alphactx.xfuncname", "^[A-Za-z].*$")); cl_git_pass(git_config_set_bool(cfg, "diff.iam_textalpha.binary", 0)); cl_git_pass(git_config_set_string( - cfg, "diff.iam_textalpha.xfuncname", "^[A-Za-z]")); + cfg, "diff.iam_textalpha.xfuncname", "^[A-Za-z].*$")); cl_git_pass(git_config_set_string( - cfg, "diff.iam_numctx.funcname", "^[0-9]")); + cfg, "diff.iam_numctx.funcname", "^[0-9][0-9]*")); cl_git_pass(git_config_set_bool(cfg, "diff.iam_textnum.binary", 0)); cl_git_pass(git_config_set_string( - cfg, "diff.iam_textnum.funcname", "^[0-9]")); + cfg, "diff.iam_textnum.funcname", "^[0-9][0-9]*")); git_config_free(cfg); cl_git_append2file( From c7c260a5ff217c822e227428e712970e02fa56d9 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 23 Jan 2014 16:12:39 -0800 Subject: [PATCH 06/12] Got some permission to use userdiff patterns I contacted a number of Git authors and lined up their permission to relicense their work for use in libgit2 and copied over their code for diff driver xfuncname patterns. At this point, the code I've copied is taken verbatim from core Git although Thomas Rast warned me that the C++ patterns, at least, really need an update. I've left off patterns where I don't feel like I have permission at this point until I hear from more authors. --- git.git-authors | 5 ++ src/diff_driver.c | 39 +---------- src/userdiff.h | 164 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 170 insertions(+), 38 deletions(-) create mode 100644 src/userdiff.h diff --git a/git.git-authors b/git.git-authors index 7d4c95bb3..9620844a9 100644 --- a/git.git-authors +++ b/git.git-authors @@ -39,8 +39,10 @@ # but has otherwise not contributed to git.) # ok Adam Simpkins (http transport) +ok Adrian Johnson ok Andreas Ericsson ok Boyd Lynn Gerber +ok Brandon Casey ok Brian Downing ok Brian Gernhardt ok Christian Couder @@ -50,11 +52,13 @@ ok Holger Weiss ok Jeff King ok Johannes Schindelin ok Johannes Sixt +ask Jonathan Nieder ok Junio C Hamano ok Kristian Høgsberg ok Linus Torvalds ok Lukas Sandström ok Matthieu Moy +ok Michael Haggerty ign Mike McCormack (imap-send) ok Nicolas Pitre ok Paolo Bonzini @@ -68,4 +72,5 @@ ok Sebastian Schuberth ok Shawn O. Pearce ok Steffen Prohaska ok Sven Verdoolaege +ask Thomas Rast (ok before 6-Oct-2013) ok Torsten Bögershausen diff --git a/src/diff_driver.c b/src/diff_driver.c index 56b5b5a51..9249d1415 100644 --- a/src/diff_driver.c +++ b/src/diff_driver.c @@ -45,44 +45,7 @@ struct git_diff_driver { char name[GIT_FLEX_ARRAY]; }; -typedef struct { - const char *name; - const char *fns; - const char *words; - int flags; -} git_diff_driver_definition; - -#define WORD_DEFAULT "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" - -/* builtin driver definition macros have same signature as in core git - * userdiff.c so that the data can be extracted verbatim - */ -#define PATTERNS(NAME, FN_PATS, WORD_PAT) \ - { NAME, FN_PATS, WORD_PAT WORD_DEFAULT, 0 } -#define IPATTERN(NAME, FN_PATS, WORD_PAT) \ - { NAME, FN_PATS, WORD_PAT WORD_DEFAULT, REG_ICASE } - -static git_diff_driver_definition builtin_defs[] = { -PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$", - "[^<>= \t]+"), -PATTERNS("java", - "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n" - "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$", - /* -- */ - "[a-zA-Z_][a-zA-Z0-9_]*" - "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" - "|[-+*/<>%&^|=!]=" - "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), -PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$", - /* -- */ - "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" - "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." - "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), -}; - -#undef IPATTERN -#undef PATTERNS -#undef WORD_DEFAULT +#include "userdiff.h" struct git_diff_driver_registry { git_strmap *drivers; diff --git a/src/userdiff.h b/src/userdiff.h new file mode 100644 index 000000000..a4f3686ad --- /dev/null +++ b/src/userdiff.h @@ -0,0 +1,164 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_userdiff_h__ +#define INCLUDE_userdiff_h__ + +/* + * This file isolates the built in diff driver function name patterns. + * Most of these patterns are taken from Git (with permission from the + * original authors for relicensing to libgit2). + */ + +typedef struct { + const char *name; + const char *fns; + const char *words; + int flags; +} git_diff_driver_definition; + +#define WORD_DEFAULT "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" + +/* + * These builtin driver definition macros have same signature as in core + * git userdiff.c so that the data can be extracted verbatim + */ +#define PATTERNS(NAME, FN_PATS, WORD_PAT) \ + { NAME, FN_PATS, WORD_PAT WORD_DEFAULT, 0 } +#define IPATTERN(NAME, FN_PATS, WORD_PAT) \ + { NAME, FN_PATS, WORD_PAT WORD_DEFAULT, REG_ICASE } + +/* + * The table of diff driver patterns + * + * Function name patterns are a list of newline separated patterns that + * match a function declaration (i.e. the line you want in the hunk header), + * or a negative pattern prefixed with a '!' to reject a pattern (such as + * rejecting goto labels in C code). + * + * Word boundary patterns are just a simple pattern that will be OR'ed with + * the default value above (i.e. whitespace or non-ASCII characters). + */ +static git_diff_driver_definition builtin_defs[] = { + +IPATTERN("ada", + "!^(.*[ \t])?(is new|renames|is separate)([ \t].*)?$\n" + "!^[ \t]*with[ \t].*$\n" + "^[ \t]*((procedure|function)[ \t]+.*)$\n" + "^[ \t]*((package|protected|task)[ \t]+.*)$", + /* -- */ + "[a-zA-Z][a-zA-Z0-9_]*" + "|[0-9][-+0-9#_.eE]" + "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"), + +IPATTERN("fortran", + "!^([C*]|[ \t]*!)\n" + "!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n" + "^[ \t]*((END[ \t]+)?(PROGRAM|MODULE|BLOCK[ \t]+DATA" + "|([^'\" \t]+[ \t]+)*(SUBROUTINE|FUNCTION))[ \t]+[A-Z].*)$", + /* -- */ + "[a-zA-Z][a-zA-Z0-9_]*" + "|\\.([Ee][Qq]|[Nn][Ee]|[Gg][TtEe]|[Ll][TtEe]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Aa][Nn][Dd]|[Oo][Rr]|[Nn]?[Ee][Qq][Vv]|[Nn][Oo][Tt])\\." + /* numbers and format statements like 2E14.4, or ES12.6, 9X. + * Don't worry about format statements without leading digits since + * they would have been matched above as a variable anyway. */ + "|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?" + "|//|\\*\\*|::|[/<>=]="), + +PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$", + "[^<>= \t]+"), + +PATTERNS("java", + "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n" + "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=" + "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), + +PATTERNS("objc", + /* Negate C statements that can look like functions */ + "!^[ \t]*(do|for|if|else|return|switch|while)\n" + /* Objective-C methods */ + "^[ \t]*([-+][ \t]*\\([ \t]*[A-Za-z_][A-Za-z_0-9* \t]*\\)[ \t]*[A-Za-z_].*)$\n" + /* C functions */ + "^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$\n" + /* Objective-C class/protocol definitions */ + "^(@(implementation|interface|protocol)[ \t].*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), + +PATTERNS("perl", + "^package .*\n" + "^sub [[:alnum:]_':]+[ \t]*" + "(\\([^)]*\\)[ \t]*)?" /* prototype */ + /* + * Attributes. A regex can't count nested parentheses, + * so just slurp up whatever we see, taking care not + * to accept lines like "sub foo; # defined elsewhere". + * + * An attribute could contain a semicolon, but at that + * point it seems reasonable enough to give up. + */ + "(:[^;#]*)?" + "(\\{[ \t]*)?" /* brace can come here or on the next line */ + "(#.*)?$\n" /* comment */ + "^(BEGIN|END|INIT|CHECK|UNITCHECK|AUTOLOAD|DESTROY)[ \t]*" + "(\\{[ \t]*)?" /* brace can come here or on the next line */ + "(#.*)?$\n" + "^=head[0-9] .*", /* POD */ + /* -- */ + "[[:alpha:]_'][[:alnum:]_']*" + "|0[xb]?[0-9a-fA-F_]*" + /* taking care not to interpret 3..5 as (3.)(.5) */ + "|[0-9a-fA-F_]+(\\.[0-9a-fA-F_]+)?([eE][-+]?[0-9_]+)?" + "|=>|-[rwxoRWXOezsfdlpSugkbctTBMAC>]|~~|::" + "|&&=|\\|\\|=|//=|\\*\\*=" + "|&&|\\|\\||//|\\+\\+|--|\\*\\*|\\.\\.\\.?" + "|[-+*/%.^&<>=!|]=" + "|=~|!~" + "|<<|<>|<=>|>>"), + +PATTERNS("python", "^[ \t]*((class|def)[ \t].*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\*\\*=?"), + +PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$", + /* -- */ + "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." + "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), + +PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", + "[={}\"]|[^={}\" \t]+"), + +PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$", + "\\\\[a-zA-Z@]+|\\\\.|[a-zA-Z0-9\x80-\xff]+"), + +PATTERNS("cpp", + /* Jump targets or access declarations */ + "!^[ \t]*[A-Za-z_][A-Za-z_0-9]*:.*$\n" + /* C/++ functions/methods at top level */ + "^([A-Za-z_][A-Za-z_0-9]*([ \t*]+[A-Za-z_][A-Za-z_0-9]*([ \t]*::[ \t]*[^[:space:]]+)?){1,}[ \t]*\\([^;]*)$\n" + /* compound type at top level */ + "^((struct|class|enum)[^;]*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), +}; + +#undef IPATTERN +#undef PATTERNS +#undef WORD_DEFAULT + +#endif + From 3b19d2fdcbd9f6185490fc10e7c4540758954321 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Fri, 24 Jan 2014 09:46:22 -0800 Subject: [PATCH 07/12] Permission for Git code from a couple more This brings over the Pascal and CSharp userdiff data. --- git.git-authors | 2 ++ src/userdiff.h | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/git.git-authors b/git.git-authors index 9620844a9..7e53d66a9 100644 --- a/git.git-authors +++ b/git.git-authors @@ -40,6 +40,7 @@ # ok Adam Simpkins (http transport) ok Adrian Johnson +ok Alexey Shumkin ok Andreas Ericsson ok Boyd Lynn Gerber ok Brandon Casey @@ -64,6 +65,7 @@ ok Nicolas Pitre ok Paolo Bonzini ok Paul Kocher ok Peter Hagervall +ok Petr Onderka ok Pierre Habouzit ok Pieter de Bie ok René Scharfe diff --git a/src/userdiff.h b/src/userdiff.h index a4f3686ad..1f2318507 100644 --- a/src/userdiff.h +++ b/src/userdiff.h @@ -94,6 +94,16 @@ PATTERNS("objc", "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), +PATTERNS("pascal", + "^(((class[ \t]+)?(procedure|function)|constructor|destructor|interface|" + "implementation|initialization|finalization)[ \t]*.*)$" + "\n" + "^(.*=[ \t]*(class|record).*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+" + "|<>|<=|>=|:=|\\.\\."), + PATTERNS("perl", "^package .*\n" "^sub [[:alnum:]_':]+[ \t]*" @@ -154,6 +164,22 @@ PATTERNS("cpp", "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), + +PATTERNS("csharp", + /* Keywords */ + "!^[ \t]*(do|while|for|if|else|instanceof|new|return|switch|case|throw|catch|using)\n" + /* Methods and constructors */ + "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[<>@._[:alnum:]]+[ \t]*\\(.*\\))[ \t]*$\n" + /* Properties */ + "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[@._[:alnum:]]+)[ \t]*$\n" + /* Type definitions */ + "^[ \t]*(((static|public|internal|private|protected|new|unsafe|sealed|abstract|partial)[ \t]+)*(class|enum|interface|struct)[ \t]+.*)$\n" + /* Namespace */ + "^[ \t]*(namespace[ \t]+.*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), }; #undef IPATTERN From 027b8edac7e91480623815193ed994db808064f6 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Fri, 24 Jan 2014 15:45:49 -0800 Subject: [PATCH 08/12] Move userdiff tests to be data driven This moves the expected and actual test data along with the source data for the userdiff tests into the tests/resources/userdiff test repo and updates the test to use that. --- tests/diff/drivers.c | 111 +++++++++--------- tests/resources/userdiff/.gitted/HEAD | Bin 0 -> 23 bytes tests/resources/userdiff/.gitted/config | Bin 0 -> 137 bytes tests/resources/userdiff/.gitted/description | Bin 0 -> 73 bytes tests/resources/userdiff/.gitted/index | Bin 0 -> 456 bytes .../05/d669073b39d36847315e3a5b4512cf4cba4546 | Bin 0 -> 54 bytes .../20/ab776b6ff3169fa0e5eff65df30d45187d22ba | Bin 0 -> 54 bytes .../23/20e2f1e4d9e6201a8e15949a0c10a533fa51cd | Bin 0 -> 207 bytes .../2e/a4b8a16d737c180dfdd2b119dec9501592326c | Bin 0 -> 228 bytes .../49/c0ff897b2b07a2ea0ed073e62a9dcd02704ba0 | Bin 0 -> 118 bytes .../50/346bde7428a29c9845470a14d87b1634293d48 | Bin 0 -> 53 bytes .../5a/428e7dcffb41b65984517f1e6b8547babc8dff | Bin 0 -> 263 bytes .../87/2d19663f32459389597b52beec6457c1dc971f | Bin 0 -> 178 bytes .../9d/b1d09ff9ad5190bcf12d72ea3c818ffca344c5 | Bin 0 -> 132 bytes .../d6/3c806de4f666369ed169495657bec24b558165 | Bin 0 -> 76 bytes .../ef/1641511d6cb425c6b4f59ef1feffe7762e86e0 | Bin 0 -> 53 bytes .../userdiff/.gitted/refs/heads/master | Bin 0 -> 41 bytes tests/resources/userdiff/after/file.html | Bin 0 -> 765 bytes tests/resources/userdiff/before/file.html | Bin 0 -> 728 bytes .../userdiff/expected/driver/diff.html | Bin 0 -> 711 bytes .../userdiff/expected/nodriver/diff.html | Bin 0 -> 614 bytes tests/resources/userdiff/files/file.html | Bin 0 -> 765 bytes 22 files changed, 57 insertions(+), 54 deletions(-) create mode 100644 tests/resources/userdiff/.gitted/HEAD create mode 100644 tests/resources/userdiff/.gitted/config create mode 100644 tests/resources/userdiff/.gitted/description create mode 100644 tests/resources/userdiff/.gitted/index create mode 100644 tests/resources/userdiff/.gitted/objects/05/d669073b39d36847315e3a5b4512cf4cba4546 create mode 100644 tests/resources/userdiff/.gitted/objects/20/ab776b6ff3169fa0e5eff65df30d45187d22ba create mode 100644 tests/resources/userdiff/.gitted/objects/23/20e2f1e4d9e6201a8e15949a0c10a533fa51cd create mode 100644 tests/resources/userdiff/.gitted/objects/2e/a4b8a16d737c180dfdd2b119dec9501592326c create mode 100644 tests/resources/userdiff/.gitted/objects/49/c0ff897b2b07a2ea0ed073e62a9dcd02704ba0 create mode 100644 tests/resources/userdiff/.gitted/objects/50/346bde7428a29c9845470a14d87b1634293d48 create mode 100644 tests/resources/userdiff/.gitted/objects/5a/428e7dcffb41b65984517f1e6b8547babc8dff create mode 100644 tests/resources/userdiff/.gitted/objects/87/2d19663f32459389597b52beec6457c1dc971f create mode 100644 tests/resources/userdiff/.gitted/objects/9d/b1d09ff9ad5190bcf12d72ea3c818ffca344c5 create mode 100644 tests/resources/userdiff/.gitted/objects/d6/3c806de4f666369ed169495657bec24b558165 create mode 100644 tests/resources/userdiff/.gitted/objects/ef/1641511d6cb425c6b4f59ef1feffe7762e86e0 create mode 100644 tests/resources/userdiff/.gitted/refs/heads/master create mode 100644 tests/resources/userdiff/after/file.html create mode 100644 tests/resources/userdiff/before/file.html create mode 100644 tests/resources/userdiff/expected/driver/diff.html create mode 100644 tests/resources/userdiff/expected/nodriver/diff.html create mode 100644 tests/resources/userdiff/files/file.html diff --git a/tests/diff/drivers.c b/tests/diff/drivers.c index 119132149..1cbf9e211 100644 --- a/tests/diff/drivers.c +++ b/tests/diff/drivers.c @@ -176,70 +176,73 @@ void test_diff_drivers__long_lines(void) void test_diff_drivers__builtins(void) { - git_index *idx; git_diff *diff; git_patch *patch; - git_buf actual = GIT_BUF_INIT; + git_buf file = GIT_BUF_INIT, actual = GIT_BUF_INIT, expected = GIT_BUF_INIT; git_diff_options opts = GIT_DIFF_OPTIONS_INIT; - const char *base = - "\n\n" - "

    \n
      \n
    1. item 1.1
    2. \n
    3. item 1.2
    4. \n
    5. item 1.3
    6. \n
    7. item 1.4
    8. \n
    9. item 1.5
    10. \n
    11. item 1.6
    12. \n
    13. item 1.7
    14. \n
    15. item 1.8
    16. \n
    17. item 1.9
    18. \n
    \n

    \n" - "

    \n
      \n
    1. item 2.1
    2. \n
    3. item 2.2
    4. \n
    5. item 2.3
    6. \n
    7. item 2.4
    8. \n
    9. item 2.5
    10. \n
    11. item 2.6
    12. \n
    13. item 2.7
    14. \n
    15. item 2.8
    16. \n
    \n

    \n" - "

    \n
      \n
    1. item 3.1
    2. \n
    3. item 3.2
    4. \n
    5. item 3.3
    6. \n
    7. item 3.4
    8. \n
    9. item 3.5
    10. \n
    11. item 3.6
    12. \n
    13. item 3.7
    14. \n
    15. item 3.8
    16. \n
    \n

    \n" - "\n"; - const char *modified = - "\n\n" - "

    \n
      \n
    1. item 1.1
    2. \n
    3. item 1.2 changed
    4. \n
    5. item 1.3 changed
    6. \n
    7. item 1.4
    8. \n
    9. item 1.5
    10. \n
    11. item 1.6
    12. \n
    13. item 1.7
    14. \n
    15. item 1.8
    16. \n
    17. item 1.9
    18. \n
    19. item 1.10 added
    20. \n
    \n

    \n" - "

    \n
      \n
    1. item 2.1
    2. \n
    3. item 2.2
    4. \n
    5. item 2.3
    6. \n
    7. item 2.4
    8. \n
    9. item 2.5
    10. \n
    11. item 2.6
    12. \n
    13. item 2.7 changed
    14. \n
    15. item 2.7.1 added
    16. \n
    17. item 2.8
    18. \n
    \n

    \n" - "

    \n
      \n
    1. item 3.1
    2. \n
    3. item 3.2
    4. \n
    5. item 3.3
    6. \n
    7. item 3.4
    8. \n
    9. item 3.5
    10. \n
    11. item 3.6
    12. \n
    \n

    \n" - "\n"; - const char *expected_nodriver = - "diff --git a/file.html b/file.html\nindex 97b34db..c7dbed3 100644\n--- a/file.html\n+++ b/file.html\n@@ -5,4 +5,4 @@\n
  • item 1.1
  • \n-
  • item 1.2
  • \n-
  • item 1.3
  • \n+
  • item 1.2 changed
  • \n+
  • item 1.3 changed
  • \n
  • item 1.4
  • \n@@ -13,2 +13,3 @@\n
  • item 1.9
  • \n+
  • item 1.10 added
  • \n \n@@ -23,3 +24,4 @@\n
  • item 2.6
  • \n-
  • item 2.7
  • \n+
  • item 2.7 changed
  • \n+
  • item 2.7.1 added
  • \n
  • item 2.8
  • \n@@ -35,4 +37,2 @@\n
  • item 3.6
  • \n-
  • item 3.7
  • \n-
  • item 3.8
  • \n \n"; - const char *expected_driver = - "diff --git a/file.html b/file.html\nindex 97b34db..c7dbed3 100644\n--- a/file.html\n+++ b/file.html\n@@ -5,4 +5,4 @@

    \n
  • item 1.1
  • \n-
  • item 1.2
  • \n-
  • item 1.3
  • \n+
  • item 1.2 changed
  • \n+
  • item 1.3 changed
  • \n
  • item 1.4
  • \n@@ -13,2 +13,3 @@

    \n
  • item 1.9
  • \n+
  • item 1.10 added
  • \n \n@@ -23,3 +24,4 @@

    \n
  • item 2.6
  • \n-
  • item 2.7
  • \n+
  • item 2.7 changed
  • \n+
  • item 2.7.1 added
  • \n
  • item 2.8
  • \n@@ -35,4 +37,2 @@

    \n
  • item 3.6
  • \n-
  • item 3.7
  • \n-
  • item 3.8
  • \n \n"; + int i; + static const char *files[] = { + "html", + NULL + }; - g_repo = cl_git_sandbox_init("empty_standard_repo"); - - cl_git_mkfile("empty_standard_repo/file.html", base); - cl_git_pass(git_repository_index(&idx, g_repo)); - cl_git_pass(git_index_add_bypath(idx, "file.html")); - cl_git_pass(git_index_write(idx)); - git_index_free(idx); - - cl_git_rewritefile("empty_standard_repo/file.html", modified); - - /* do diff with no special driver */ + g_repo = cl_git_sandbox_init("userdiff"); opts.interhunk_lines = 1; opts.context_lines = 1; + opts.pathspec.count = 1; - cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); - cl_assert_equal_sz(1, git_diff_num_deltas(diff)); - cl_git_pass(git_patch_from_diff(&patch, diff, 0)); - cl_git_pass(git_patch_to_buf(&actual, patch)); + for (i = 0; files[i]; ++i) { + git_buf_sets(&file, "files/file."); + git_buf_puts(&file, files[i]); + opts.pathspec.strings = &file.ptr; - overwrite_filemode(expected_nodriver, &actual); + /* do diff with no special driver */ - cl_assert_equal_s(expected_nodriver, actual.ptr); + cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); + cl_assert_equal_sz(1, git_diff_num_deltas(diff)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); + cl_git_pass(git_patch_to_buf(&actual, patch)); + git_buf_sets(&expected, "userdiff/expected/nodriver/diff."); + git_buf_puts(&expected, files[i]); + cl_git_pass(git_futils_readbuffer(&expected, expected.ptr)); + + overwrite_filemode(expected.ptr, &actual); + + cl_assert_equal_s(expected.ptr, actual.ptr); + + git_buf_clear(&actual); + git_patch_free(patch); + git_diff_free(diff); + + /* do diff with driver */ + + { + FILE *fp = fopen("userdiff/.gitattributes", "w"); + fprintf(fp, "*.%s diff=%s\n", files[i], files[i]); + fclose(fp); + } + + cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); + cl_assert_equal_sz(1, git_diff_num_deltas(diff)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); + cl_git_pass(git_patch_to_buf(&actual, patch)); + + git_buf_sets(&expected, "userdiff/expected/driver/diff."); + git_buf_puts(&expected, files[i]); + cl_git_pass(git_futils_readbuffer(&expected, expected.ptr)); + + overwrite_filemode(expected.ptr, &actual); + + cl_assert_equal_s(expected.ptr, actual.ptr); + + git_buf_clear(&actual); + git_patch_free(patch); + git_diff_free(diff); + } + + git_buf_free(&file); git_buf_free(&actual); - git_patch_free(patch); - git_diff_free(diff); - - /* do diff with HTML driver */ - - cl_git_mkfile("empty_standard_repo/.gitattributes", "*.html diff=html\n"); - - cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); - cl_assert_equal_sz(1, git_diff_num_deltas(diff)); - cl_git_pass(git_patch_from_diff(&patch, diff, 0)); - cl_git_pass(git_patch_to_buf(&actual, patch)); - - overwrite_filemode(expected_driver, &actual); - - cl_assert_equal_s(expected_driver, actual.ptr); - - git_buf_free(&actual); - git_patch_free(patch); - git_diff_free(diff); + git_buf_free(&expected); } diff --git a/tests/resources/userdiff/.gitted/HEAD b/tests/resources/userdiff/.gitted/HEAD new file mode 100644 index 0000000000000000000000000000000000000000..cb089cd89a7d7686d284d8761201649346b5aa1c GIT binary patch literal 23 ecmXR)O|w!cN=+-)&qz&7Db~+TEG|hc;sO9;xClW2 literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/config b/tests/resources/userdiff/.gitted/config new file mode 100644 index 0000000000000000000000000000000000000000..6c9406b7d9320db083eca69b3f8bee9a6c7b50d4 GIT binary patch literal 137 zcmYk#%?-jZ3KJaaM(b)IThRcka) zn6vinzTI-FENHqTG;JZL7ug4u#6zM7i5Th{J5BgE#z&9!LjG%xu(tTZ>RkRd-|~Df A#{d8T literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/description b/tests/resources/userdiff/.gitted/description new file mode 100644 index 0000000000000000000000000000000000000000..498b267a8c7812490d6479839c5577eaaec79d62 GIT binary patch literal 73 zcmWH|%S+5nO;IRHEyyp$t+PQ$;d2LNXyJgRZve!Elw`VEGWs$&r??@ Q$yWgB0LrH#Y0~2Y0PnOK(EtDd literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/index b/tests/resources/userdiff/.gitted/index new file mode 100644 index 0000000000000000000000000000000000000000..9372411cd8c99727a1e81c014a562905310f5a69 GIT binary patch literal 456 zcmZ?q402{*U|<4b)}TjU<^X917|qAPz``c7^b-R^;}Ql2#;-sr5unn)$_kG@KDqf! zL8?!5$}Ap%rN+Mk&ob~Qrj?`?>8EApr0Qjqx$$uxT- z*U6oc)j|8-q=X;5GhLoRASpF1zbF;iz@SGz)W#*?z{H%{%4R(ttd!ME=f(%PbtbQ1G+RNGc66`QlPn~pyq;UsJVe?=BDW_*|9LU zxJH8a@1>2B_f7_gPBO}2kcOL^mycmG$W%~x{#=brL&HHD&3x?Pzz+)1V&q_8Xv%nB Weue9Yj_3;O-W#%iejl%nY6Ad&0h1sA literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/objects/05/d669073b39d36847315e3a5b4512cf4cba4546 b/tests/resources/userdiff/.gitted/objects/05/d669073b39d36847315e3a5b4512cf4cba4546 new file mode 100644 index 0000000000000000000000000000000000000000..3a9d75cc163f2208427b0d4eaee474b5a999683f GIT binary patch literal 54 zcmbS>LWXA=X$D!zO?c{ZIZsCH3s+D8r@(|@8B KVhjNZ0(Sv0TNSea literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/objects/20/ab776b6ff3169fa0e5eff65df30d45187d22ba b/tests/resources/userdiff/.gitted/objects/20/ab776b6ff3169fa0e5eff65df30d45187d22ba new file mode 100644 index 0000000000000000000000000000000000000000..3d57061ce386d3709125f1ba2a3bd0d830b7698c GIT binary patch literal 54 zcmbwA5)&uY+SGZ5Gj^O3AG%&;Zy?I zlp|4sBT<4QQ6fJe4^<)e6YqNZ!2NRY#t#1&kYzxY0a*qV90RfpxH9aUreuER;VP$B J{|3DL&q1teT{8dx literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/objects/2e/a4b8a16d737c180dfdd2b119dec9501592326c b/tests/resources/userdiff/.gitted/objects/2e/a4b8a16d737c180dfdd2b119dec9501592326c new file mode 100644 index 0000000000000000000000000000000000000000..e7d2fba413542584e7d20152fa21c50db040c612 GIT binary patch literal 228 zcmV*(0>fV5^BSy-F)oNvJOD!s828YpJl9gg?yZedzqX zgG%X*aeWU$T-*q4(K~M+?<%k3;GtV9%-xKA!oEhM4waNhSX%5sm1U(h6GHsEFwS|# zscAs$wieIl|GtCrQ1pdLSxJ6u=g=<+WTXZqfN?Sa literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/objects/49/c0ff897b2b07a2ea0ed073e62a9dcd02704ba0 b/tests/resources/userdiff/.gitted/objects/49/c0ff897b2b07a2ea0ed073e62a9dcd02704ba0 new file mode 100644 index 0000000000000000000000000000000000000000..49d59c11da8e1f8de8bfe0911c6734c4349993b2 GIT binary patch literal 118 zcmV-+0Ez#20V^p=O;s>7HexU_00M=?w35^!2G(nt?ADf-Gu#d1tfF0o&im|gb%V$! zrKaTv-jcPFyO9XD~D{Ff%bxNXyJg)ypW!&0%QQl}xiYa-G~6Ssk?RO-lH| LJJaO>IKL0@AuS0hLkBj)Nc&-ZM`z>6L==v)U%E>8oggN!Hbvb$WbM+WD)4c8wt0D}9GU$rU>mlybpy%?+?TFQi0-kiT0H z#&~1X=>+6^F9F9AE>*|Cs-K;)x6#9>&)yFGu0{|~g0TlL{FP zz4{mxr^Q5*M#X74voBl)I5nL{7TT1p^d-}WcP8TTt)dLcEdJGZ_V!t<*cK~ZVp9)- NKI!I^egW=F!^3*Ohh6{x literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/objects/87/2d19663f32459389597b52beec6457c1dc971f b/tests/resources/userdiff/.gitted/objects/87/2d19663f32459389597b52beec6457c1dc971f new file mode 100644 index 0000000000000000000000000000000000000000..415f40a66e519f4f508d37590237af22ab52b6fc GIT binary patch literal 178 zcmbjws5qsw93!TiZvRTi+B%)YnJF;nwt=gp_{bL@=X3PcAN z)&|W#wor3R@7>j!J%R6iUc7s1e8$_z`@e^x-&3p3pL0*Tw_j+v(tm7X@NE76Qxioa z&ToiI*n24IVASEN-yvIPyR9wX|Awb8xcoudi!`S^wI@i#uU+3;PPYH#&=5d@)ec*4 QvpwgJ75~L+6njV#0He85n*aa+ literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/objects/9d/b1d09ff9ad5190bcf12d72ea3c818ffca344c5 b/tests/resources/userdiff/.gitted/objects/9d/b1d09ff9ad5190bcf12d72ea3c818ffca344c5 new file mode 100644 index 0000000000000000000000000000000000000000..c0a03a241e2809895730fb6ae6f5928a1e1cd747 GIT binary patch literal 132 zcmV-~0DJ#<0hNtS4#FT1MqP7?xqxO$E0n|->K%(B!XhWBEQfwDPURF7@>I`8AZ|If?x+8#g@ i9XD~D{Ff%bxNXbk~)5|Ey&0&ag>Z?8f+i_cDOJKcRcB}iY LJ-z<{P2mx8BYhWi literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/refs/heads/master b/tests/resources/userdiff/.gitted/refs/heads/master new file mode 100644 index 0000000000000000000000000000000000000000..2ec79ec86a14ae18a5aba85543fd26aa1f0e4351 GIT binary patch literal 41 ucmV~$$q@h`2n4Xd)o_kb4u{)+2`0JCO9^DHb5ajj_R1@r-~gu7Z2Wxw4-32i literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/after/file.html b/tests/resources/userdiff/after/file.html new file mode 100644 index 0000000000000000000000000000000000000000..2320e2f1e4d9e6201a8e15949a0c10a533fa51cd GIT binary patch literal 765 zcmajdT@HdU37`J#X&bvkWJDr^W;%GmX^_NJA~7hD7?em1rW@q3 rih4cqs;4j9KZoFax5q#t1BnbIG7w4(Br?#P9ZtKh%^0#sfTGzQAi>rZhHGlLQ5%Mh&$hL^WbPKL+=~C=kW54 zF&dpo;nqIWG#4{>kCO7(E|Xl}nR>KOK9z1Tj-1+h`L7JCz0<}9fy|^ z^fVP62(_0$LskFraGYtE#&T$kc}t3n+0fM_vdFlfN}VPZG8%gGF)GQ6i6)Io@^WTh vxC(G;I*lx}xmf8-rVqcFsMoiuG9RA}|FloAP*!xpqsr7=th@$bSo=NYHE2C?56;IY&-gSbwE zKl{nuKudip!iI^BjCq-6nQu?SwQt7G*?gPQb{t+Kn0YFaYT6<2P$|cHT7`J#X&bvkWJDr^W;%GmX^_NJA~7hD7?em1rW@q3 rih4cqs;4j9KZoFax5q#t1BnbIG7w4(Br?# Date: Fri, 24 Jan 2014 15:46:15 -0800 Subject: [PATCH 09/12] Add PHP and Javascript diff drivers Since I don't have permission yet on the code from Git, I decided I'd take a stab at writing patterns for PHP and Javascript myself. I think these are pretty weak, but probably better than the default behavior without them. --- src/userdiff.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/userdiff.h b/src/userdiff.h index 1f2318507..318761567 100644 --- a/src/userdiff.h +++ b/src/userdiff.h @@ -180,6 +180,22 @@ PATTERNS("csharp", "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), + +PATTERNS("php", + "^[ \t]*((public|private|protected|static|final)[ \t]+)*((class|function)[ \t].*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), + +PATTERNS("javascript", + "^[ \t]*(\(?function[ \t].*)$\n" + "^[ \t]*(var[ \t]+[a-zA-Z_][a-zA-Z0-9_]*[ \t]*=[ \t]*function[ \t\(].*)$\n" + "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*[ \t]*:[ \t]*function[ \t\(].*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?" + "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), }; #undef IPATTERN From 4115987739fb9cc4dd82edd9998db6dbb6bc9d95 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 27 Jan 2014 10:23:55 -0800 Subject: [PATCH 10/12] Got permission from Gustaf for userdiff patterns --- git.git-authors | 1 + src/userdiff.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/git.git-authors b/git.git-authors index 7e53d66a9..7c72c4bf6 100644 --- a/git.git-authors +++ b/git.git-authors @@ -49,6 +49,7 @@ ok Brian Gernhardt ok Christian Couder ok Daniel Barkalow ok Florian Forster +ok Gustaf Hendeby ok Holger Weiss ok Jeff King ok Johannes Schindelin diff --git a/src/userdiff.h b/src/userdiff.h index 318761567..93b4d0d58 100644 --- a/src/userdiff.h +++ b/src/userdiff.h @@ -80,6 +80,10 @@ PATTERNS("java", "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS("matlab", + "^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$", + "[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\.[*/\\^']|\\|\\||&&"), + PATTERNS("objc", /* Negate C statements that can look like functions */ "!^[ \t]*(do|for|if|else|return|switch|while)\n" From 082e82dba5b5174756b3a5fc2e385ccc59626164 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 27 Jan 2014 11:45:06 -0800 Subject: [PATCH 11/12] Update Javascript userdiff driver and tests Writing a sample Javascript driver pointed out some extra whitespace handling that needed to be done in the diff driver. This adds some tests with some sample javascript code that I pulled off of GitHub just to see what would happen. Also, to clean up the userdiff test data, I did a "git gc" and packed up the test objects. --- src/diff_driver.c | 1 + src/userdiff.h | 6 ++-- tests/diff/drivers.c | 28 ++++++++++-------- tests/resources/userdiff/.gitted/index | Bin 456 -> 912 bytes tests/resources/userdiff/.gitted/info/refs | Bin 0 -> 59 bytes .../05/d669073b39d36847315e3a5b4512cf4cba4546 | Bin 54 -> 0 bytes .../20/ab776b6ff3169fa0e5eff65df30d45187d22ba | Bin 54 -> 0 bytes .../23/20e2f1e4d9e6201a8e15949a0c10a533fa51cd | Bin 207 -> 0 bytes .../2e/a4b8a16d737c180dfdd2b119dec9501592326c | Bin 228 -> 0 bytes .../49/c0ff897b2b07a2ea0ed073e62a9dcd02704ba0 | Bin 118 -> 0 bytes .../50/346bde7428a29c9845470a14d87b1634293d48 | Bin 53 -> 0 bytes .../5a/428e7dcffb41b65984517f1e6b8547babc8dff | Bin 263 -> 0 bytes .../87/2d19663f32459389597b52beec6457c1dc971f | Bin 178 -> 0 bytes .../9d/b1d09ff9ad5190bcf12d72ea3c818ffca344c5 | Bin 132 -> 0 bytes .../d6/3c806de4f666369ed169495657bec24b558165 | Bin 76 -> 0 bytes .../ef/1641511d6cb425c6b4f59ef1feffe7762e86e0 | Bin 53 -> 0 bytes .../userdiff/.gitted/objects/info/packs | Bin 0 -> 54 bytes ...f78c35e3ca74fffd9d6c2b6dcd60d6ab6a614a.idx | Bin 0 -> 2192 bytes ...78c35e3ca74fffd9d6c2b6dcd60d6ab6a614a.pack | Bin 0 -> 5697 bytes tests/resources/userdiff/.gitted/packed-refs | Bin 0 -> 98 bytes .../userdiff/.gitted/refs/heads/master | Bin 41 -> 0 bytes .../resources/userdiff/after/file.javascript | Bin 0 -> 2785 bytes .../resources/userdiff/before/file.javascript | Bin 0 -> 2812 bytes .../userdiff/expected/driver/diff.javascript | Bin 0 -> 1343 bytes .../expected/nodriver/diff.javascript | Bin 0 -> 1181 bytes .../resources/userdiff/files/file.javascript | Bin 0 -> 2785 bytes 26 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 tests/resources/userdiff/.gitted/info/refs delete mode 100644 tests/resources/userdiff/.gitted/objects/05/d669073b39d36847315e3a5b4512cf4cba4546 delete mode 100644 tests/resources/userdiff/.gitted/objects/20/ab776b6ff3169fa0e5eff65df30d45187d22ba delete mode 100644 tests/resources/userdiff/.gitted/objects/23/20e2f1e4d9e6201a8e15949a0c10a533fa51cd delete mode 100644 tests/resources/userdiff/.gitted/objects/2e/a4b8a16d737c180dfdd2b119dec9501592326c delete mode 100644 tests/resources/userdiff/.gitted/objects/49/c0ff897b2b07a2ea0ed073e62a9dcd02704ba0 delete mode 100644 tests/resources/userdiff/.gitted/objects/50/346bde7428a29c9845470a14d87b1634293d48 delete mode 100644 tests/resources/userdiff/.gitted/objects/5a/428e7dcffb41b65984517f1e6b8547babc8dff delete mode 100644 tests/resources/userdiff/.gitted/objects/87/2d19663f32459389597b52beec6457c1dc971f delete mode 100644 tests/resources/userdiff/.gitted/objects/9d/b1d09ff9ad5190bcf12d72ea3c818ffca344c5 delete mode 100644 tests/resources/userdiff/.gitted/objects/d6/3c806de4f666369ed169495657bec24b558165 delete mode 100644 tests/resources/userdiff/.gitted/objects/ef/1641511d6cb425c6b4f59ef1feffe7762e86e0 create mode 100644 tests/resources/userdiff/.gitted/objects/info/packs create mode 100644 tests/resources/userdiff/.gitted/objects/pack/pack-03f78c35e3ca74fffd9d6c2b6dcd60d6ab6a614a.idx create mode 100644 tests/resources/userdiff/.gitted/objects/pack/pack-03f78c35e3ca74fffd9d6c2b6dcd60d6ab6a614a.pack create mode 100644 tests/resources/userdiff/.gitted/packed-refs delete mode 100644 tests/resources/userdiff/.gitted/refs/heads/master create mode 100644 tests/resources/userdiff/after/file.javascript create mode 100644 tests/resources/userdiff/before/file.javascript create mode 100644 tests/resources/userdiff/expected/driver/diff.javascript create mode 100644 tests/resources/userdiff/expected/nodriver/diff.javascript create mode 100644 tests/resources/userdiff/files/file.javascript diff --git a/src/diff_driver.c b/src/diff_driver.c index 9249d1415..4c9a0af65 100644 --- a/src/diff_driver.c +++ b/src/diff_driver.c @@ -437,6 +437,7 @@ static int diff_context_line__pattern_match( i = (pmatch[1].rm_so >= 0) ? 1 : 0; git_buf_consume(line, git_buf_cstr(line) + pmatch[i].rm_so); git_buf_truncate(line, pmatch[i].rm_eo - pmatch[i].rm_so); + git_buf_rtrim(line); return true; } diff --git a/src/userdiff.h b/src/userdiff.h index 93b4d0d58..2257035ac 100644 --- a/src/userdiff.h +++ b/src/userdiff.h @@ -193,9 +193,9 @@ PATTERNS("php", "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), PATTERNS("javascript", - "^[ \t]*(\(?function[ \t].*)$\n" - "^[ \t]*(var[ \t]+[a-zA-Z_][a-zA-Z0-9_]*[ \t]*=[ \t]*function[ \t\(].*)$\n" - "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*[ \t]*:[ \t]*function[ \t\(].*)$", + "^[ \t]*(function[ \t][a-zA-Z_][^\{]*)\n" + "^[ \t]*(var[ \t]+[a-zA-Z_][a-zA-Z0-9_]*[ \t]*=[ \t]*function[ \t\(][^\{]*)\n" + "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*[ \t]*:[ \t]*function[ \t\(][^\{]*)", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?" diff --git a/tests/diff/drivers.c b/tests/diff/drivers.c index 1cbf9e211..8b12368ea 100644 --- a/tests/diff/drivers.c +++ b/tests/diff/drivers.c @@ -180,22 +180,23 @@ void test_diff_drivers__builtins(void) git_patch *patch; git_buf file = GIT_BUF_INIT, actual = GIT_BUF_INIT, expected = GIT_BUF_INIT; git_diff_options opts = GIT_DIFF_OPTIONS_INIT; - int i; - static const char *files[] = { - "html", - NULL - }; + git_vector files = GIT_VECTOR_INIT; + size_t i; + char *path, *extension; g_repo = cl_git_sandbox_init("userdiff"); + cl_git_pass(git_path_dirload("userdiff/files", 9, 0, 0, &files)); + opts.interhunk_lines = 1; opts.context_lines = 1; opts.pathspec.count = 1; - for (i = 0; files[i]; ++i) { - git_buf_sets(&file, "files/file."); - git_buf_puts(&file, files[i]); - opts.pathspec.strings = &file.ptr; + git_vector_foreach(&files, i, path) { + if (git__prefixcmp(path, "files/file.")) + continue; + extension = path + strlen("files/file."); + opts.pathspec.strings = &path; /* do diff with no special driver */ @@ -205,7 +206,7 @@ void test_diff_drivers__builtins(void) cl_git_pass(git_patch_to_buf(&actual, patch)); git_buf_sets(&expected, "userdiff/expected/nodriver/diff."); - git_buf_puts(&expected, files[i]); + git_buf_puts(&expected, extension); cl_git_pass(git_futils_readbuffer(&expected, expected.ptr)); overwrite_filemode(expected.ptr, &actual); @@ -220,7 +221,7 @@ void test_diff_drivers__builtins(void) { FILE *fp = fopen("userdiff/.gitattributes", "w"); - fprintf(fp, "*.%s diff=%s\n", files[i], files[i]); + fprintf(fp, "*.%s diff=%s\n", extension, extension); fclose(fp); } @@ -230,7 +231,7 @@ void test_diff_drivers__builtins(void) cl_git_pass(git_patch_to_buf(&actual, patch)); git_buf_sets(&expected, "userdiff/expected/driver/diff."); - git_buf_puts(&expected, files[i]); + git_buf_puts(&expected, extension); cl_git_pass(git_futils_readbuffer(&expected, expected.ptr)); overwrite_filemode(expected.ptr, &actual); @@ -240,9 +241,12 @@ void test_diff_drivers__builtins(void) git_buf_clear(&actual); git_patch_free(patch); git_diff_free(diff); + + git__free(path); } git_buf_free(&file); git_buf_free(&actual); git_buf_free(&expected); + git_vector_free(&files); } diff --git a/tests/resources/userdiff/.gitted/index b/tests/resources/userdiff/.gitted/index index 9372411cd8c99727a1e81c014a562905310f5a69..df041cf72ffbe78022a7b77cdef8226d064d9171 100644 GIT binary patch literal 912 zcmZ?q402{*U|<4buAoO><^X917|qAPz``c7^b-R^;}Ql2#;-sr5unn)$_kG@KDqf! zL8?!5$}Ap%rN+Mk&ob~Qrj?`?>8EApr0Qjq?_XJ)B0@w?D{D({Skv0vU#Wu4SMurJ;a?58sg54k*MY}9glMAt3ChQaa&|dV7**+ ztNX4!z5f{`Q!5HmlS@)l^izs5%YY%9l9`qU3E7}$TUS8b3!x$IRgpn8m(|`c^+HLS zswtb$)PMey-1M|gE)~^dkjH8+io=2KJ_U6*n1;GL5Y>F9G`%G|7UmY$Nbvr>v{CZj z$pFzwMmY@9aP#x>FLN9;RQ{`4b2&+ubw+Q zF_u9Qhxtf80H%-CVDq6g#Qi&^QO(DZKKMZ?xEMKkfZWRsbuXBPxK|+-)jS;OLlnt8 eBsYT0ThL*DKwEbE@^sPQ>kntLO%z`$O delta 56 zcmbQheuA0D#WTp6fq{Vuh*>A{1Ww!CzVcmN} L_RsI*)lqE#!?zS6 diff --git a/tests/resources/userdiff/.gitted/info/refs b/tests/resources/userdiff/.gitted/info/refs new file mode 100644 index 0000000000000000000000000000000000000000..261695f80d7283e93499ac68a2943dba7c42fc2e GIT binary patch literal 59 zcmV~$!4be92n4`)(u|ti04WC%#*ZJd|H-b@hhLb~)*}o=gFa#E25ATetEwUV+8$Y^ L>&UV+kMH{j=rIwq literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/objects/05/d669073b39d36847315e3a5b4512cf4cba4546 b/tests/resources/userdiff/.gitted/objects/05/d669073b39d36847315e3a5b4512cf4cba4546 deleted file mode 100644 index 3a9d75cc163f2208427b0d4eaee474b5a999683f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmbS>LWXA=X$D!zO?c{ZIZsCH3s+D8r@(|@8B KVhjNZ0(Sv0TNSea diff --git a/tests/resources/userdiff/.gitted/objects/20/ab776b6ff3169fa0e5eff65df30d45187d22ba b/tests/resources/userdiff/.gitted/objects/20/ab776b6ff3169fa0e5eff65df30d45187d22ba deleted file mode 100644 index 3d57061ce386d3709125f1ba2a3bd0d830b7698c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmbwA5)&uY+SGZ5Gj^O3AG%&;Zy?I zlp|4sBT<4QQ6fJe4^<)e6YqNZ!2NRY#t#1&kYzxY0a*qV90RfpxH9aUreuER;VP$B J{|3DL&q1teT{8dx diff --git a/tests/resources/userdiff/.gitted/objects/2e/a4b8a16d737c180dfdd2b119dec9501592326c b/tests/resources/userdiff/.gitted/objects/2e/a4b8a16d737c180dfdd2b119dec9501592326c deleted file mode 100644 index e7d2fba413542584e7d20152fa21c50db040c612..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 228 zcmV*(0>fV5^BSy-F)oNvJOD!s828YpJl9gg?yZedzqX zgG%X*aeWU$T-*q4(K~M+?<%k3;GtV9%-xKA!oEhM4waNhSX%5sm1U(h6GHsEFwS|# zscAs$wieIl|GtCrQ1pdLSxJ6u=g=<+WTXZqfN?Sa diff --git a/tests/resources/userdiff/.gitted/objects/49/c0ff897b2b07a2ea0ed073e62a9dcd02704ba0 b/tests/resources/userdiff/.gitted/objects/49/c0ff897b2b07a2ea0ed073e62a9dcd02704ba0 deleted file mode 100644 index 49d59c11da8e1f8de8bfe0911c6734c4349993b2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 118 zcmV-+0Ez#20V^p=O;s>7HexU_00M=?w35^!2G(nt?ADf-Gu#d1tfF0o&im|gb%V$! zrKaTv-jcPFyO9XD~D{Ff%bxNXyJg)ypW!&0%QQl}xiYa-G~6Ssk?RO-lH| LJJaO>IKL0@AuS0hLkBj)Nc&-ZM`z>6L==v)U%E>8oggN!Hbvb$WbM+WD)4c8wt0D}9GU$rU>mlybpy%?+?TFQi0-kiT0H z#&~1X=>+6^F9F9AE>*|Cs-K;)x6#9>&)yFGu0{|~g0TlL{FP zz4{mxr^Q5*M#X74voBl)I5nL{7TT1p^d-}WcP8TTt)dLcEdJGZ_V!t<*cK~ZVp9)- NKI!I^egW=F!^3*Ohh6{x diff --git a/tests/resources/userdiff/.gitted/objects/87/2d19663f32459389597b52beec6457c1dc971f b/tests/resources/userdiff/.gitted/objects/87/2d19663f32459389597b52beec6457c1dc971f deleted file mode 100644 index 415f40a66e519f4f508d37590237af22ab52b6fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 178 zcmbjws5qsw93!TiZvRTi+B%)YnJF;nwt=gp_{bL@=X3PcAN z)&|W#wor3R@7>j!J%R6iUc7s1e8$_z`@e^x-&3p3pL0*Tw_j+v(tm7X@NE76Qxioa z&ToiI*n24IVASEN-yvIPyR9wX|Awb8xcoudi!`S^wI@i#uU+3;PPYH#&=5d@)ec*4 QvpwgJ75~L+6njV#0He85n*aa+ diff --git a/tests/resources/userdiff/.gitted/objects/9d/b1d09ff9ad5190bcf12d72ea3c818ffca344c5 b/tests/resources/userdiff/.gitted/objects/9d/b1d09ff9ad5190bcf12d72ea3c818ffca344c5 deleted file mode 100644 index c0a03a241e2809895730fb6ae6f5928a1e1cd747..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 132 zcmV-~0DJ#<0hNtS4#FT1MqP7?xqxO$E0n|->K%(B!XhWBEQfwDPURF7@>I`8AZ|If?x+8#g@ i9XD~D{Ff%bxNXbk~)5|Ey&0&ag>Z?8f+i_cDOJKcRcB}iY LJ-z<{P2mx8BYhWi diff --git a/tests/resources/userdiff/.gitted/objects/info/packs b/tests/resources/userdiff/.gitted/objects/info/packs new file mode 100644 index 0000000000000000000000000000000000000000..6970fd7b0116e62a6db0752767b061bafcb642a1 GIT binary patch literal 54 zcmWGgC`e4s)-^CrGq*@KHcd57PBb@3OG`_!OfgF~N-|4HPBAk`F-uG`OEfbyNz?ToEoCWSh;bx<8tQLCf&qVQ2kh1*`ErDc9AG;kSjr$vg zBsbIro?HB8@u`+&wIeQ6%QW`O2_r27CFb(dE_KcBT%;sCBkGBDSiko0TS|M6DB{&& zv!vWV8;X<=uJQOk_63KJXy)X04ZQIlL6fxEhC(BJ$55xZ8?Vd3rJqKr39QFF8VTIy zt7gvi*X*3gZnCm>)wdLJ`KC;t_z~k`87q9~&VDss)SL??=Xzg?#+uaO!CrB@A8QSX zOATmdG6*Y`G%}`WX>JxvZwqi1?l!>^rpejtEE0JEww0x6W9qohD~-DMQeOfl{F$zh z<20P9db8hly9>zt_)Qy_>VtXj8iLFeetj?0+W;4!YPm znH>7#^JY`IO9un*K5S}C^*+#2n^!Q{oASNPL%L;rp(D~nV`nVUra`W9!Ywo?G5A&- zjTv2VYbs$!k4WJl&%avYATVr?tgKUHUrjXEVXU?yojAIU<$0se->bSUbMaB9d1& z&aJKGiNZ$%Tqx0wwOVQ_$^=8Zzw2uF$-Al?Gw{mgRr2|cs_2eFzv{b%ZDt+2R#HNq zALpj5cXuCuOirhj4Vi?|L&Jg}xZ0oOI7|rNV>3JMy)C*>CCJ-)mxx{N8jCe=6K!QQ z8Sjy^Kc_-xI!SV_sJ9FRbv?^?_e#n_Q4~>*shW5zNsp7{B8!p zd9SPK&ByR6Z-Tg}g*a-3czFtE9z-q;{@dl?lOU=h0eJVx`9e&k!n_Zh>mmADKu<2fa0lcoCLJPm8SJ9KM?)R*5z9v)6ea-3J4`ir$hrk2h-~m`ouH4yZ(6}8K^e>( z1HB(+`rw{YsG;wPeG+ZgcRQjhEsLuS%-bJqM2nW5Xxg1i4>&Rz9W_c!IxJ D#Jn9@ literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/objects/pack/pack-03f78c35e3ca74fffd9d6c2b6dcd60d6ab6a614a.pack b/tests/resources/userdiff/.gitted/objects/pack/pack-03f78c35e3ca74fffd9d6c2b6dcd60d6ab6a614a.pack new file mode 100644 index 0000000000000000000000000000000000000000..5b263e27dcf3abc8fa2f73979b0c5d76b289665c GIT binary patch literal 5697 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 literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/.gitted/refs/heads/master b/tests/resources/userdiff/.gitted/refs/heads/master deleted file mode 100644 index 2ec79ec86a14ae18a5aba85543fd26aa1f0e4351..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 41 ucmV~$$q@h`2n4Xd)o_kb4u{)+2`0JCO9^DHb5ajj_R1@r-~gu7Z2Wxw4-32i diff --git a/tests/resources/userdiff/after/file.javascript b/tests/resources/userdiff/after/file.javascript new file mode 100644 index 0000000000000000000000000000000000000000..7cd3c5a8aaf0e89037ff51ea54fb1c3d0828125c GIT binary patch literal 2785 zcmb_eQE%He5Poic#jOvuop^HEhdspghHlG{3~dvv!GIwM3Pw6v%xF;~DSKY)|Gqm? zq@~6|_b?*}Z1VWs-FM#|IXgZA_@Gw^xh@d!Z)ZgAuz=F&6;#eO_G~s=N>{b_S*};J zhgL~ZE2X!^%;rWb^&75HsO-TK(x#Gm1(j$TtSvYV_Xq-Jm1>!bY1v`Mj?C5UoX1$g%|6HjOq8WKAgd6zr=b z!no{Z^UzucmebUw2j^_3v_e+4wGHNumZb&yt2HQHFVVnSC|M9vFYIvcz9nalD65^2 zlqlA^T~_2ztQv*T2Bd5JzmA(L%ez+NCeNO~3t#guF!eyTlE%aRFm?0Q6zNTuHJfybk$x6jm-! zE-N>>n|ezi4r|Ihy1gCw-(MQpkmue?Q^Cx&(G4269o_k$fNJboL+N(DUkC6B{Lpzh z>!O;I?;U5}&*Q2rEjk#Z>ZhUo>WywF#M2lvP*vIZEtZ_&Y3IJsUH+6+3FB|1eJ|b< zUY0;65t>;_t8lV_z7?FnOAe7gyGYXkKz4rs(MQ#X`$Pt!|`Nqiz<|k_5%!;H=|toCO>NDX!tM@Y<;pPB8zi@%LRCJ>S`y<)xW4B)jd%`G zm1NDcrBfvjH)%7Z_O-P0#u%~95^`pF4raMfYTR{d_E(E$`+*MRPMbHhF}f{;6W{h@ zyBkd=QBxj26=MOVP!iOV zLiy=2znb7-pU; z6eiMh!1xgEV>1e($8wk06keU4Cerp)byt%pit{xMs<+ZQq}yXW3ha;Qg6->K8kCrT zo;)6Cq2q%(43F=oL4UL3#sB%Ci`omWC!jC8J5)E^s!SjYwcpDtsF)nX^pk>4UUR2z|@yrt=m76HgBMu!p4H&}|)(qHT&b7%&7y!AO+Fj21PLvX`~~@B5Av zWqL``JxmB3o4ot(?z@jCE{>0g-kY_g(o~YtE$Y3SHbeAZ;5}Hq?l&ldU6f=vI;-Z)IDlc15qmM!-pRo~-N) zZGlUor8k$?q*VzYn0w&(Mv_;^>XNp?(bm{M*x$4{MDL`nR9%znyUtioss+j|l6`gr zjLWQ=yWV+nT&Af5I9EHz3ani3I$3%wD@XWi4QbP^q@|6}ssd7$cJ#aL5zK?K)(eF~ zWo!CXgLq=yX-S>%UfM_ir(PT#FOJTqb>Eg=p@!*JwUyb<=o9BTK^^40Ri&St^TI}0 zs!aJ(%QY>*5!)76=-0CK;}_n>@8B^aucZG?$t|;SK~oMuco?wM3f90IkZ&e&Z!TW58b`H!PSCr>>Ro6~>no6Cg zXTs{W=@9xfVoPaGVCI1S+MjVa;P>5GKzp9F&{ zT5(^D$c5t(SCm5Q>2L^(KYMBK-@~Ew#=gMDt)6ijOJNf|j~G9O`_K$YWGoMb&FR_c zp0qtx!@EpW)yoYe_F6eF@w%B#BKs4(k#k+lqrOM>zvv!mf%`!p4&8V2sK3SW^8bAB zW)FhP1oZEj5xW~-!%QFxH6I%J*!V9;jPdwnJTmdazzC{i8?Q7E^zh{8t2aO4a>W`k nqLS4U^m4pC$&F7+9uyH(6JzkHklTZ>@kECSw40^N*ZI*u?cq~P literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/expected/driver/diff.javascript b/tests/resources/userdiff/expected/driver/diff.javascript new file mode 100644 index 0000000000000000000000000000000000000000..4e65d074662535061295fe4f92462e2ac9a5152e GIT binary patch literal 1343 zcmb7D$!^;)5Isj4*>AP8ugl3389LDEi_^xr!}Ew-~1 zEf0h=e0-dF^JXow48kxM7Fa(Mk{h>2-`Jj+REw>J)yr{DlxzMSR|Py__!y4zuB%#txzT8+skOr2HiKpT(fJ8M#=%csBNzY zznU5V+A#PFIEJ+q`~?F(#F$#Oe!C2lQ7{ERNrK5qhQg4RDC||)$WFNiP_*fy{MZn_ zMitO3N=p3nPx{pDwc-Qjxh*g0j*I6Jxjt-oo2JgdW4WyS(i%)lW{Ntf@=!Pr3d!eQw5petTM2Gjm)kD+urt?%8K!# zG`+jP3mq1CRWXIQ14@*K+n)PwQFD*{11e}ynr>^sPROJwnYvN3X3E_6?&cnNR`YOT zH4mq_wweKW4*fS=U(@S86Oqhw&CC~B`#$_?wE}cyAPYE!bxQw&0Rjn1Xr4!>Bpn4) zAZZ#*PL$vTIXkco8o_IoLf|Wbf|;*auB9@ozTeFcP{s<8otS2JLEFdfqYXqL!Dr_R z{rQoR^%=)UX^h-DA`2&$wi~P^c>!>o(zA{w(vyWO<$;lq>p<7}T(ob~??I=q2q{Nos7OK=^!@mr~b0l=q<8%_oP$$$!RyadJe zj0zoqQM@Ra;#FaH+cU>)kQMsTe2qC|n0x#QbkyF3DY=epRY$p0S2Qd8`L4{b_S*};J zhgL~ZE2X!^%;rWb^&75HsO-TK(x#Gm1(j$TtSvYV_Xq-Jm1>!bY1v`Mj?C5UoX1$g%|6HjOq8WKAgd6zr=b z!no{Z^UzucmebUw2j^_3v_e+4wGHNumZb&yt2HQHFVVnSC|M9vFYIvcz9nalD65^2 zlqlA^T~_2ztQv*T2Bd5JzmA(L%ez+NCeNO~3t#guF!eyTlE%aRFm?0Q6zNTuHJfybk$x6jm-! zE-N>>n|ezi4r|Ihy1gCw-(MQpkmue?Q^Cx&(G4269o_k$fNJboL+N(DUkC6B{Lpzh z>!O;I?;U5}&*Q2rEjk#Z>ZhUo>WywF#M2lvP*vIZEtZ_&Y3IJsUH+6+3FB|1eJ|b< zUY0;65t>;_t8lV_z7?FnOAe7gyGYXkKz4rs(MQ#X`$Pt!|`Nqiz<|k_5%!;H=|toCO>NDX!tM@Y<;pPB8zi@%LRCJ>S`y<)xW4B)jd%`G zm1NDcrBfvjH)%7Z_O-P0#u%~95^`pF4raMfYTR{d_E(E$`+*MRPMbHhF}f{;6W{h@ zyBkd=QBxj26=MOVP!iOV zLiy=2znb7-pU; z6eiMh!1xgEV>1e($8wk06keU4Cerp)byt%pit{xMs<+ZQq}yXW3ha;Qg6->K8kCrT zo;)6Cq2q%(43F=oL4UL3#sB%Ci`omWC!jC8J5)E^s!SjYwcpDtsF)nX^pk>4UUR2z|@yrt= Date: Mon, 27 Jan 2014 14:57:03 -0800 Subject: [PATCH 12/12] Add PHP tests and fix bug in PHP builtin driver --- src/userdiff.h | 2 +- tests/resources/userdiff/.gitted/index | Bin 912 -> 1336 bytes tests/resources/userdiff/.gitted/info/refs | Bin 59 -> 59 bytes .../userdiff/.gitted/objects/info/packs | Bin 54 -> 54 bytes ...f78c35e3ca74fffd9d6c2b6dcd60d6ab6a614a.idx | Bin 2192 -> 0 bytes ...52578900ac63564f2a24b9714529821276ceb9.idx | Bin 0 -> 2500 bytes ...578900ac63564f2a24b9714529821276ceb9.pack} | Bin 5697 -> 7102 bytes tests/resources/userdiff/.gitted/packed-refs | Bin 98 -> 98 bytes .../userdiff/.gitted/refs/dummy-marker.txt | Bin tests/resources/userdiff/after/file.php | Bin 0 -> 1338 bytes tests/resources/userdiff/before/file.php | Bin 0 -> 1310 bytes .../userdiff/expected/driver/diff.php | Bin 0 -> 1011 bytes .../userdiff/expected/nodriver/diff.php | Bin 0 -> 950 bytes tests/resources/userdiff/files/file.php | Bin 0 -> 1338 bytes 14 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 tests/resources/userdiff/.gitted/objects/pack/pack-03f78c35e3ca74fffd9d6c2b6dcd60d6ab6a614a.idx create mode 100644 tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.idx rename tests/resources/userdiff/.gitted/objects/pack/{pack-03f78c35e3ca74fffd9d6c2b6dcd60d6ab6a614a.pack => pack-1652578900ac63564f2a24b9714529821276ceb9.pack} (56%) create mode 100644 tests/resources/userdiff/.gitted/refs/dummy-marker.txt create mode 100644 tests/resources/userdiff/after/file.php create mode 100644 tests/resources/userdiff/before/file.php create mode 100644 tests/resources/userdiff/expected/driver/diff.php create mode 100644 tests/resources/userdiff/expected/nodriver/diff.php create mode 100644 tests/resources/userdiff/files/file.php diff --git a/src/userdiff.h b/src/userdiff.h index 2257035ac..9318b5476 100644 --- a/src/userdiff.h +++ b/src/userdiff.h @@ -186,7 +186,7 @@ PATTERNS("csharp", "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"), PATTERNS("php", - "^[ \t]*((public|private|protected|static|final)[ \t]+)*((class|function)[ \t].*)$", + "^[ \t]*(((public|private|protected|static|final)[ \t]+)*((class|function)[ \t].*))$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?" diff --git a/tests/resources/userdiff/.gitted/index b/tests/resources/userdiff/.gitted/index index df041cf72ffbe78022a7b77cdef8226d064d9171..b69d5cfb169871c97c93f562deb25d9580880f5e 100644 GIT binary patch delta 470 zcmbQhzJrU$#WTp6fq{Vui1{b-tn_~NND#DQ zSgoejrlg%pJ=EA9{C6GGbb}S&RxnRu;7d#^NiEV(%gjmDE66CAxM8i&vptLu=di0?9s0yJXdv3Hv@lCYFd6#D%`xuk&JsnpFKJNG6?8C zFby%#*96r-=Figww{Cv}Ut3o#vzd-iAo)MPLXHCYQgD;=^3lu& znF$1wFEg!733~SMD2M~2p`jauY6mO!;NSy=YcV`DK;{&5w&kpSBbz_@w7p616q`G* HikKn+KIV{Y delta 57 zcmdnNHG!SS#WTp6fq{Vuh`A>6tenisxMK2O#vPM+nGa0XWmzt=pu_%vw(R!h>7v2c NAI@Z(D7a*)5dhhd6IK8K diff --git a/tests/resources/userdiff/.gitted/info/refs b/tests/resources/userdiff/.gitted/info/refs index 261695f80d7283e93499ac68a2943dba7c42fc2e..b0743141df0eba528a297b88a790ad5f527bc190 100644 GIT binary patch literal 59 zcmXprNHtC~PckwwNi;P!FikZ|woFSjNli0IwXif#Gfpxz0TLD|DV#;AX~p^(sfj7Y M`nie4C8<{9 literal 59 zcmV~$!4be92n4`)(u|ti04WC%#*ZJd|H-b@hhLb~)*}o=gFa#E25ATetEwUV+8$Y^ L>&UV+kMH{j=rIwq diff --git a/tests/resources/userdiff/.gitted/objects/info/packs b/tests/resources/userdiff/.gitted/objects/info/packs index 6970fd7b0116e62a6db0752767b061bafcb642a1..0c5fc2a30bd433b5dcfa3a3e60b63d7f5c367d4d 100644 GIT binary patch literal 54 zcmWGgC`e4s)-^OUH8M4~urx48Og1w%H8V*wN;EP_vNSg|F*UNZFfueUH%m@UveW~q H=HdbXeaa2U literal 54 zcmWGgC`e4s)-^CrGq*@KHcd57PBb@3OG`_!OfgF~N-|4HPBAk`F-uG`OEfbyNz?ToEoCWSh;bx<8tQLCf&qVQ2kh1*`ErDc9AG;kSjr$vg zBsbIro?HB8@u`+&wIeQ6%QW`O2_r27CFb(dE_KcBT%;sCBkGBDSiko0TS|M6DB{&& zv!vWV8;X<=uJQOk_63KJXy)X04ZQIlL6fxEhC(BJ$55xZ8?Vd3rJqKr39QFF8VTIy zt7gvi*X*3gZnCm>)wdLJ`KC;t_z~k`87q9~&VDss)SL??=Xzg?#+uaO!CrB@A8QSX zOATmdG6*Y`G%}`WX>JxvZwqi1?l!>^rpejtEE0JEww0x6W9qohD~-DMQeOfl{F$zh z<20P9db8hly9>zt_)Qy_>VtXj8iLFeetj?0+W;4!YPm znH>7#^JY`IO9un*K5S}C^*+#2n^!Q{oASNPL%L;rp(D~nV`nVUra`W9!Ywo?G5A&- zjTv2VYbs$!k4WJl&%avYATVr?tgKUHUrjXEVXU?yojAIU<$0se->bSUbMaB9d1& z&aJKGiNZ$%Tqx0wwOVQ_$^=8Zzw2uF$-Al?Gw{mgRr2|cs_2eFzv{b%ZDt+2R#HNq zALpj5cXuCuOirhj4Vi?|L&Jg}xZ0oOI7|rNV>3JMy)C*>CCJ-)mxx{N8jCe=6K!QQ z8Sjy^Kc_-xI!SV_sJ9FRbv?^?_e#n_Q4~>*shW5zNsp7{B8!p zd9SPK&ByR6Z-Tg}g*a-3czFtE9z-q;{@dl?lOU=h0eJVx`9e&k!n_Zh>mmADKu<2fa0lcoCLJPm8SJ9KM?)R*5z9v)6ea-3J4`ir$hrk2h-~m`ouH4yZ(6}8K^e>( z1HB(+`rw{YsG;wPeG+ZgcRQjhEsLuS%-bJqM2nW5Xxg1i4>&Rz9W_c!IxJ D#Jn9@ diff --git a/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.idx b/tests/resources/userdiff/.gitted/objects/pack/pack-1652578900ac63564f2a24b9714529821276ceb9.idx new file mode 100644 index 0000000000000000000000000000000000000000..6f4381cc71d74b46cc055ed8585ea6e07d58c179 GIT binary patch literal 2500 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 P!;J?Obst>u;k^U^A}cl0 diff --git a/tests/resources/userdiff/.gitted/packed-refs b/tests/resources/userdiff/.gitted/packed-refs index 6d24ee4ed87cf77b89a62132830eb862131457d6..802f67ce0e182d91a06726faa7f5982db6c5a56a 100644 GIT binary patch delta 64 zcmYdFnxJlNW{_%}W}akZVv=ZTY+#ydlx&%nXp)*{kZNIRo@Sh6XaXcGQc@I(Qqzj{ RGg1>%iuH37i%U|AxBzC%6V?C# delta 64 zcmV~$u@QhU2nEpIDeNqh=s&=78X#~sHi?5cvhSIF+a-1911_~$rh}-{DNN>&hGej+ SIx^M~Im;c|XL)qKF_s@xmlJ>h diff --git a/tests/resources/userdiff/.gitted/refs/dummy-marker.txt b/tests/resources/userdiff/.gitted/refs/dummy-marker.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/resources/userdiff/after/file.php b/tests/resources/userdiff/after/file.php new file mode 100644 index 0000000000000000000000000000000000000000..967d6466ca65c2818753fdae029730a8f6a80392 GIT binary patch literal 1338 zcmbtUO>fgc5Iy5xF-S&rK1$&n2oeZ5ArJ_0XsT$t8ON*IyJkO{R4D(wGhWAboN|FZ zM7A^Y=Dj!1e)Fy_>Lk&kLRSlk@JZaET_nlXbeg~vzFD(>fZSLxzCa6G)M$k_*3H2i zu;_!;V08HaL95>Z;a-#h-Anjo?45(1@&)5Gu&d9xlCmyai#cc*rIsycrj6 zOC=!>T6$$Ptk=?L=WUQa>!=N=%pvWElNvgaH(#Z`Q0{Ws@uq2G5reWGhwBD+Gk6{O zA0o$QLEJcn55mg=gx;`Ev@TJW{h~n9t%KX(|Guq;G4Fu!>ND|M^jRuASxYE5*4JjB zl}T37yg~W==q;Jc@c%}ib3{PfP@(q!rzY~_#M9b3$g!$ak^iqEWu~oi$et_b*owH& zHayoUL)}a!gOzi`lU2i{aS@+Gbf2y^W{hEx!^w=-!J%DqBG)mi@pl|9lEic-C(?Qq zJTFzV+36G3MtYYNxG1fU-B=X^_`;eUXxzc->pj}MG`o*`i8a3}nX9eRKF=<`h`p*p z#i8R@5=;&+HgqRsL9a3I(@-RHr8i1%L7aR(E{OgalQuuhfKPAR0d|Ed5i+G)Z&LED egBb6r*Z$;+u5ZW&>Tf>6ldj literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/before/file.php b/tests/resources/userdiff/before/file.php new file mode 100644 index 0000000000000000000000000000000000000000..63250ad0197d0103425d2123488f2c139d25bc8b GIT binary patch literal 1310 zcmbtUO>fgc5WV|X43bgpG^N}NK>`6M1VTa_nkw3^$MLGpuGx<|5z2pO#_QOQTQ0B% z%j=zw_ujnqn|DpsB#9O~bd8V*pTq;&nD2)ZIzXN{(?)ua$%{Xz7*Fu-QnX zowq^yY``$-xrB7=La=E?fc%#FO1Z1m0Fb)P(N4m~Ivh9dBKBj%*G++w7VtrMS%J_6 zi$OCHbv;f4ByAns2mkkxbZA*5cq_W#Ew;$vIW$cB=0R;q;Tg>sIm$KmxxxlK9sF3%_9WnRxlOcnAm z+?*um`^uUYG`6t*`iQoyP5W^#vEf^ixyCB(%k1Kd*sERGvFG^Ofhpl-K|3KUx~e=* zLyjz!E|lJaIQvCh5c;V31W9inM!;)S@d$0DYJ^PbUYe9-8%oT_Hd23fVz+m6JA<*UIbiJ^aw@1`H zOH6dK1L6L~*=p`39(sDOp{cn}ZcaMab=tHG60h-N)J;5IIISGrp!=^95M(3sbI+CM zt1JbSZ~eo8zCwnZCJF^^siVMZZ(Ayi9wDA)ow+lWj>Wwl&LDcrwWcN-{f}q+yRUX1 z$M7^Ah2Qb2Y@UP{_2YSVHkW-Xxu~nC50p5P(rT(oA6z-)JIt3sI8;v@pCQlKyorz_ zG|R}p^2i~Fn-`KPBF}mXX)bj^4wv9u>m_Hy)Jh&e&;#6kf24{v^6=$IXy@-=q&vlh zVbRq$eB`ZdK@Ha)B!hRATVYbWAL77GEv*6OeoQX*fMG}k9&uyom4jVaao7JJ`*tVG literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/expected/nodriver/diff.php b/tests/resources/userdiff/expected/nodriver/diff.php new file mode 100644 index 0000000000000000000000000000000000000000..e77c094aaf7d77c0eb67b3615ce0d56a0cad0f01 GIT binary patch literal 950 zcmah|U2mH(6n!4Q;#Q(6kwXe0qnn~teW~^|P1@9_c8XlM4wk^C{%A5){qM7ZCNxN^ zAFjFPaPPV2n36LFalGXQ=q2Md>MkzYs)fgsgMfMHb}6tu24R-@W5D~e5TQ6Eo5pF_uS z=60&Kwn1UEGxN~jKZKl+kstoZj~sHio|@xlJs2{EI@5Z?kJe3e@pw}yxdVYac=-8@ ziq&#=yDzXcT#87yiVMS{iyw5)8{2^DZ!Sm%=cUVNQMo(4 literal 0 HcmV?d00001 diff --git a/tests/resources/userdiff/files/file.php b/tests/resources/userdiff/files/file.php new file mode 100644 index 0000000000000000000000000000000000000000..967d6466ca65c2818753fdae029730a8f6a80392 GIT binary patch literal 1338 zcmbtUO>fgc5Iy5xF-S&rK1$&n2oeZ5ArJ_0XsT$t8ON*IyJkO{R4D(wGhWAboN|FZ zM7A^Y=Dj!1e)Fy_>Lk&kLRSlk@JZaET_nlXbeg~vzFD(>fZSLxzCa6G)M$k_*3H2i zu;_!;V08HaL95>Z;a-#h-Anjo?45(1@&)5Gu&d9xlCmyai#cc*rIsycrj6 zOC=!>T6$$Ptk=?L=WUQa>!=N=%pvWElNvgaH(#Z`Q0{Ws@uq2G5reWGhwBD+Gk6{O zA0o$QLEJcn55mg=gx;`Ev@TJW{h~n9t%KX(|Guq;G4Fu!>ND|M^jRuASxYE5*4JjB zl}T37yg~W==q;Jc@c%}ib3{PfP@(q!rzY~_#M9b3$g!$ak^iqEWu~oi$et_b*owH& zHayoUL)}a!gOzi`lU2i{aS@+Gbf2y^W{hEx!^w=-!J%DqBG)mi@pl|9lEic-C(?Qq zJTFzV+36G3MtYYNxG1fU-B=X^_`;eUXxzc->pj}MG`o*`i8a3}nX9eRKF=<`h`p*p z#i8R@5=;&+HgqRsL9a3I(@-RHr8i1%L7aR(E{OgalQuuhfKPAR0d|Ed5i+G)Z&LED egBb6r*Z$;+u5ZW&>Tf>6ldj literal 0 HcmV?d00001