Skip to content

Commit b31607a

Browse files
pks-tgitster
authored andcommitted
entry: refactor how we remove items for delayed checkouts
When finalizing a delayed checkout, we sort out several strings from the passed-in string list by first assigning the empty string to those filters and then calling `string_list_remove_empty_items()`. Assigning the empty string will cause compiler warnings though as the string is a `char *` once we enable `-Wwrite-strings`. Refactor the code to use a `NULL` pointer with `filter_string_list()` instead to avoid this warning. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 394affd commit b31607a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

entry.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ static int remove_available_paths(struct string_list_item *item, void *cb_data)
167167
return !available;
168168
}
169169

170+
static int string_is_not_null(struct string_list_item *item, void *data UNUSED)
171+
{
172+
return !!item->string;
173+
}
174+
170175
int finish_delayed_checkout(struct checkout *state, int show_progress)
171176
{
172177
int errs = 0;
@@ -189,7 +194,7 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)
189194
if (!async_query_available_blobs(filter->string, &available_paths)) {
190195
/* Filter reported an error */
191196
errs = 1;
192-
filter->string = "";
197+
filter->string = NULL;
193198
continue;
194199
}
195200
if (available_paths.nr <= 0) {
@@ -199,7 +204,7 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)
199204
* filter from the list (see
200205
* "string_list_remove_empty_items" call below).
201206
*/
202-
filter->string = "";
207+
filter->string = NULL;
203208
continue;
204209
}
205210

@@ -225,7 +230,7 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)
225230
* Do not ask the filter for available blobs,
226231
* again, as the filter is likely buggy.
227232
*/
228-
filter->string = "";
233+
filter->string = NULL;
229234
continue;
230235
}
231236
ce = index_file_exists(state->istate, path->string,
@@ -239,7 +244,8 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)
239244
errs = 1;
240245
}
241246
}
242-
string_list_remove_empty_items(&dco->filters, 0);
247+
248+
filter_string_list(&dco->filters, 0, string_is_not_null, NULL);
243249
}
244250
stop_progress(&progress);
245251
string_list_clear(&dco->filters, 0);

0 commit comments

Comments
 (0)