aboutsummaryrefslogtreecommitdiffstats
path: root/chdir-notify.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-11-19 08:50:59 +0100
committerJunio C Hamano <gitster@pobox.com>2025-11-25 12:16:00 -0800
commit2574c617362a0c67d15fa01e01cdbd0f6bcdbc93 (patch)
tree2aa602afe629654706d9c0fc021795c7f27592de /chdir-notify.c
parent35d9fc65edc0a5df9f714d02afaa2c942fb28570 (diff)
downloadgit-2574c617362a0c67d15fa01e01cdbd0f6bcdbc93.tar.gz
chdir-notify: add function to unregister listeners
While we (obviously) have a way to register new listeners that get called whenever we chdir(3p), we don't have an equivalent that can be used to unregister such a listener again. Add one, as it will be required in a subsequent commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'chdir-notify.c')
-rw-r--r--chdir-notify.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/chdir-notify.c b/chdir-notify.c
index 0d7bc04607..f8bfe3cbef 100644
--- a/chdir-notify.c
+++ b/chdir-notify.c
@@ -25,6 +25,24 @@ void chdir_notify_register(const char *name,
list_add_tail(&e->list, &chdir_notify_entries);
}
+void chdir_notify_unregister(const char *name, chdir_notify_callback cb,
+ void *data)
+{
+ struct list_head *pos, *p;
+
+ list_for_each_safe(pos, p, &chdir_notify_entries) {
+ struct chdir_notify_entry *e =
+ list_entry(pos, struct chdir_notify_entry, list);
+
+ if (e->cb != cb || e->data != data || !e->name != !name ||
+ (e->name && strcmp(e->name, name)))
+ continue;
+
+ list_del(pos);
+ free(e);
+ }
+}
+
static void reparent_cb(const char *name,
const char *old_cwd,
const char *new_cwd,