summaryrefslogtreecommitdiff
path: root/convert.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-02-28 13:25:57 -0800
committerJunio C Hamano <gitster@pobox.com>2012-02-28 13:25:57 -0800
commit524ee675a36961c5b59302e84ffd08808f4f787e (patch)
treed64fc7d9b88c9be517e87fdf82f8a3fb31ee5f01 /convert.c
parent25a7850a106ed0f27b88b8ce0b89fd326120dff4 (diff)
parent36daaaca0046542f4d5576ad5766ac55f43e3fc3 (diff)
downloadgit-524ee675a36961c5b59302e84ffd08808f4f787e.tar.gz
Merge branch 'jb/required-filter'
* jb/required-filter: Add a setting to require a filter to be successful Conflicts: convert.c
Diffstat (limited to 'convert.c')
-rw-r--r--convert.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/convert.c b/convert.c
index 4534e2c2b0..66021550c3 100644
--- a/convert.c
+++ b/convert.c
@@ -452,6 +452,7 @@ static struct convert_driver {
struct convert_driver *next;
const char *smudge;
const char *clean;
+ int required;
} *user_convert, **user_convert_tail;
static int read_convert_config(const char *var, const char *value, void *cb)
@@ -495,6 +496,11 @@ static int read_convert_config(const char *var, const char *value, void *cb)
if (!strcmp("clean", ep))
return git_config_string(&drv->clean, var, value);
+ if (!strcmp("required", ep)) {
+ drv->required = git_config_bool(var, value);
+ return 0;
+ }
+
return 0;
}
@@ -773,13 +779,19 @@ int convert_to_git(const char *path, const char *src, size_t len,
{
int ret = 0;
const char *filter = NULL;
+ int required = 0;
struct conv_attrs ca;
convert_attrs(&ca, path);
- if (ca.drv)
+ if (ca.drv) {
filter = ca.drv->clean;
+ required = ca.drv->required;
+ }
ret |= apply_filter(path, src, len, dst, filter);
+ if (!ret && required)
+ die("%s: clean filter '%s' failed", path, ca.drv->name);
+
if (ret && dst) {
src = dst->buf;
len = dst->len;
@@ -797,13 +809,16 @@ static int convert_to_working_tree_internal(const char *path, const char *src,
size_t len, struct strbuf *dst,
int normalizing)
{
- int ret = 0;
+ int ret = 0, ret_filter = 0;
const char *filter = NULL;
+ int required = 0;
struct conv_attrs ca;
convert_attrs(&ca, path);
- if (ca.drv)
+ if (ca.drv) {
filter = ca.drv->smudge;
+ required = ca.drv->required;
+ }
ret |= ident_to_worktree(path, src, len, dst, ca.ident);
if (ret) {
@@ -822,7 +837,12 @@ static int convert_to_working_tree_internal(const char *path, const char *src,
len = dst->len;
}
}
- return ret | apply_filter(path, src, len, dst, filter);
+
+ ret_filter = apply_filter(path, src, len, dst, filter);
+ if (!ret_filter && required)
+ die("%s: smudge filter %s failed", path, ca.drv->name);
+
+ return ret | ret_filter;
}
int convert_to_working_tree(const char *path, const char *src, size_t len, struct strbuf *dst)