summaryrefslogtreecommitdiff
path: root/string-list.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-06-13 13:26:59 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-06-13 13:27:00 -0700
commite350625b68cf747e4933239735ceb111f4375a83 (patch)
treec7e292cbe43023dbe625dbb4655c26a7f11d7ee6 /string-list.c
parentMerge branch 'jk/bug-to-abort' into maint (diff)
parentusage.c: drop set_error_handle() (diff)
downloadtgif-e350625b68cf747e4933239735ceb111f4375a83.tar.xz
Merge branch 'bw/forking-and-threading' into maint
The "run-command" API implementation has been made more robust against dead-locking in a threaded environment. * bw/forking-and-threading: usage.c: drop set_error_handle() run-command: restrict PATH search to executable files run-command: expose is_executable function run-command: block signals between fork and execve run-command: add note about forking and threading run-command: handle dup2 and close errors in child run-command: eliminate calls to error handling functions in child run-command: don't die in child when duping /dev/null run-command: prepare child environment before forking string-list: add string_list_remove function run-command: use the async-signal-safe execv instead of execvp run-command: prepare command before forking t0061: run_command executes scripts without a #! line t5550: use write_script to generate post-update hook
Diffstat (limited to 'string-list.c')
-rw-r--r--string-list.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/string-list.c b/string-list.c
index 003ca1879e..c650500c6e 100644
--- a/string-list.c
+++ b/string-list.c
@@ -64,6 +64,24 @@ struct string_list_item *string_list_insert(struct string_list *list, const char
return list->items + index;
}
+void string_list_remove(struct string_list *list, const char *string,
+ int free_util)
+{
+ int exact_match;
+ int i = get_entry_index(list, string, &exact_match);
+
+ if (exact_match) {
+ if (list->strdup_strings)
+ free(list->items[i].string);
+ if (free_util)
+ free(list->items[i].util);
+
+ list->nr--;
+ memmove(list->items + i, list->items + i + 1,
+ (list->nr - i) * sizeof(struct string_list_item));
+ }
+}
+
int string_list_has_string(const struct string_list *list, const char *string)
{
int exact_match;