Skip to content

Commit 4b193b1

Browse files
New checkout option: disabled_filters
It is a string array of the filters you want to disable in checkout
1 parent 30d5c08 commit 4b193b1

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

include/git2/checkout.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ typedef enum {
182182
* notifications; don't update the working directory or index.
183183
*/
184184
GIT_CHECKOUT_DRY_RUN = (1u << 24),
185-
185+
186186
/**
187187
* THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
188188
*/
@@ -339,6 +339,7 @@ typedef struct git_checkout_options {
339339

340340
/** Payload passed to perfdata_cb */
341341
void *perfdata_payload;
342+
git_strarray disabled_filters;
342343
} git_checkout_options;
343344

344345
#define GIT_CHECKOUT_OPTIONS_VERSION 1

src/checkout.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ static int blob_content_to_file(
15671567

15681568
filter_session.attr_session = &data->attr_session;
15691569
filter_session.temp_buf = &buffers->tmp;
1570-
1570+
filter_session.disabled_filters = &data->opts.disabled_filters;
15711571
if (!data->opts.disable_filters) {
15721572
git_mutex_lock(&data->index_mutex);
15731573

@@ -2425,6 +2425,7 @@ static int checkout_write_merge(
24252425

24262426
filter_session.attr_session = &data->attr_session;
24272427
filter_session.temp_buf = &buffers->tmp;
2428+
filter_session.disabled_filters = &data->opts.disabled_filters;
24282429

24292430
if ((error = git_filter_list__load(
24302431
&fl, data->repo, NULL, result.path,
@@ -2998,7 +2999,7 @@ int git_checkout_iterator(
29982999

29993000
if (data.strategy & GIT_CHECKOUT_DRY_RUN)
30003001
goto cleanup;
3001-
3002+
30023003
data.total_steps = counts[CHECKOUT_ACTION__REMOVE] +
30033004
counts[CHECKOUT_ACTION__REMOVE_CONFLICT] +
30043005
counts[CHECKOUT_ACTION__UPDATE_BLOB] +

src/filter.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ int git_filter_list__load(
514514
git_filter_session *filter_session)
515515
{
516516
int error = 0;
517+
int i;
518+
int disabled_filter_found;
517519
git_filter_list *fl = NULL;
518520
git_filter_source src = { 0 };
519521
git_filter_entry *fe;
@@ -541,6 +543,19 @@ int git_filter_list__load(
541543
if (!fdef || !fdef->filter)
542544
continue;
543545

546+
if (filter_session->disabled_filters) {
547+
disabled_filter_found = 0;
548+
for (i = 0; i < filter_session->disabled_filters->count; ++i) {
549+
char *filter = filter_session->disabled_filters->strings[i];
550+
if (!strcmp(filter, fdef->filter_name)) {
551+
disabled_filter_found = 1;
552+
break;
553+
}
554+
}
555+
if (disabled_filter_found)
556+
continue;
557+
}
558+
544559
if (fdef->nattrs > 0) {
545560
error = filter_list_check_attributes(
546561
&values, repo,

src/filter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ typedef struct {
2020
git_filter_options options;
2121
git_attr_session *attr_session;
2222
git_buf *temp_buf;
23+
git_strarray *disabled_filters;
2324
} git_filter_session;
2425

2526
#define GIT_FILTER_SESSION_INIT {GIT_FILTER_OPTIONS_INIT, 0}

0 commit comments

Comments
 (0)