diff options
author | Russell Belfer <rb@github.com> | 2013-09-15 22:23:39 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-09-17 09:31:46 -0700 |
commit | eab3746b3026950ed62842c1e5641556d7131a5b (patch) | |
tree | aa9b33b4a10b6e70db3daf9b79831a959f3fbb4c /src/ident.c | |
parent | 37f9e4093999498a25641018da36245d6a7cb008 (diff) | |
download | libgit2-eab3746b3026950ed62842c1e5641556d7131a5b.tar.gz |
More filtering tests including order
This adds more tests of filters, including the ident filter when
mixed with custom filters. I was able to combine with the reverse
filter and demonstrate that the order of filter application with
the default priority constants matches the order of core Git.
Also, this fixes two issues in the ident filter: preventing ident
expansion on binary files and avoiding a NULL dereference when
dollar sign characters are found without Id.
Diffstat (limited to 'src/ident.c')
-rw-r--r-- | src/ident.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ident.c b/src/ident.c index 3ea949859..23c407f16 100644 --- a/src/ident.c +++ b/src/ident.c @@ -8,6 +8,7 @@ #include "git2/sys/filter.h" #include "filter.h" #include "buffer.h" +#include "buf_text.h" static int ident_find_id( const char **id_start, const char **id_end, const char *start, size_t len) @@ -24,7 +25,7 @@ static int ident_find_id( len = remaining - 1; } - if (len < 3) + if (!found || len < 3) return GIT_ENOTFOUND; *id_start = found; @@ -99,6 +100,10 @@ static int ident_apply( { GIT_UNUSED(self); GIT_UNUSED(payload); + /* Don't filter binary files */ + if (git_buf_text_is_binary(from)) + return GIT_ENOTFOUND; + if (git_filter_source_mode(src) == GIT_FILTER_SMUDGE) return ident_insert_id(to, from, src); else |