| 70 | } |
| 71 | |
| 72 | int chdir_notify(const char *new_cwd) |
| 73 | { |
| 74 | struct strbuf old_cwd = STRBUF_INIT; |
| 75 | struct list_head *pos; |
| 76 | |
| 77 | if (strbuf_getcwd(&old_cwd) < 0) |
| 78 | return -1; |
| 79 | if (chdir(new_cwd) < 0) { |
| 80 | int saved_errno = errno; |
| 81 | strbuf_release(&old_cwd); |
| 82 | errno = saved_errno; |
| 83 | return -1; |
| 84 | } |
| 85 | |
| 86 | trace_printf_key(&trace_setup_key, |
| 87 | "setup: chdir from '%s' to '%s'", |
| 88 | old_cwd.buf, new_cwd); |
| 89 | |
| 90 | list_for_each(pos, &chdir_notify_entries) { |
| 91 | struct chdir_notify_entry *e = |
| 92 | list_entry(pos, struct chdir_notify_entry, list); |
| 93 | e->cb(e->name, old_cwd.buf, new_cwd, e->data); |
| 94 | } |
| 95 | |
| 96 | strbuf_release(&old_cwd); |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | char *reparent_relative_path(const char *old_cwd, |
| 101 | const char *new_cwd, |
no test coverage detected