diff options
author | Vincent Ambo <mail@tazj.in> | 2021-09-21T10·03+0300 |
---|---|---|
committer | Vincent Ambo <mail@tazj.in> | 2021-09-21T11·29+0300 |
commit | 43b1791ec601732ac31195df96781a848360a9ac (patch) | |
tree | daae8d638343295d2f1f7da955e556ef4c958864 /third_party/git/chdir-notify.c | |
parent | 2d8e7dc9d9c38127ec4ebd13aee8e8f586a43318 (diff) |
chore(3p/git): Unvendor git and track patches instead r/2903
This was vendored a long time ago under the expectation that keeping it in sync with cgit would be easier this way, but it has proven not to be a big issue. On the other hand, a vendored copy of git is an annoying maintenance burden. It is much easier to rebase the single (dottime) patch that we have. This removes the vendored copy of git and instead passes the git source code to cgit via `pkgs.srcOnly`, which includes the applied patch so that cgit can continue rendering dottime. Change-Id: If31f62dea7ce688fd1b9050204e9378019775f2b
Diffstat (limited to 'third_party/git/chdir-notify.c')
-rw-r--r-- | third_party/git/chdir-notify.c | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/third_party/git/chdir-notify.c b/third_party/git/chdir-notify.c deleted file mode 100644 index 5f7f2c2ac236..000000000000 --- a/third_party/git/chdir-notify.c +++ /dev/null @@ -1,93 +0,0 @@ -#include "cache.h" -#include "chdir-notify.h" -#include "list.h" -#include "strbuf.h" - -struct chdir_notify_entry { - const char *name; - chdir_notify_callback cb; - void *data; - struct list_head list; -}; -static LIST_HEAD(chdir_notify_entries); - -void chdir_notify_register(const char *name, - chdir_notify_callback cb, - void *data) -{ - struct chdir_notify_entry *e = xmalloc(sizeof(*e)); - e->name = name; - e->cb = cb; - e->data = data; - list_add_tail(&e->list, &chdir_notify_entries); -} - -static void reparent_cb(const char *name, - const char *old_cwd, - const char *new_cwd, - void *data) -{ - char **path = data; - char *tmp = *path; - - if (!tmp) - return; - - *path = reparent_relative_path(old_cwd, new_cwd, tmp); - free(tmp); - - if (name) { - trace_printf_key(&trace_setup_key, - "setup: reparent %s to '%s'", - name, *path); - } -} - -void chdir_notify_reparent(const char *name, char **path) -{ - chdir_notify_register(name, reparent_cb, path); -} - -int chdir_notify(const char *new_cwd) -{ - struct strbuf old_cwd = STRBUF_INIT; - struct list_head *pos; - - if (strbuf_getcwd(&old_cwd) < 0) - return -1; - if (chdir(new_cwd) < 0) { - int saved_errno = errno; - strbuf_release(&old_cwd); - errno = saved_errno; - return -1; - } - - trace_printf_key(&trace_setup_key, - "setup: chdir from '%s' to '%s'", - old_cwd.buf, new_cwd); - - list_for_each(pos, &chdir_notify_entries) { - struct chdir_notify_entry *e = - list_entry(pos, struct chdir_notify_entry, list); - e->cb(e->name, old_cwd.buf, new_cwd, e->data); - } - - strbuf_release(&old_cwd); - return 0; -} - -char *reparent_relative_path(const char *old_cwd, - const char *new_cwd, - const char *path) -{ - char *ret, *full; - - if (is_absolute_path(path)) - return xstrdup(path); - - full = xstrfmt("%s/%s", old_cwd, path); - ret = xstrdup(remove_leading_path(full, new_cwd)); - free(full); - - return ret; -} |