# The path from one directory to a file, expressed relative to that directory. # # The pre-receive hook is this same binary reached through a symlink, because # that is how git's core.hooksPath finds it. An absolute symlink would be a # hook that works at exactly one prefix; a relative one survives a staged # install (DESTDIR), a prefix built elsewhere, and a container image that moves # /usr/local around - and `ls -l` still says what the hook is. BEGIN { n = split(from, f, "/") m = split(to, t, "/") i = 1 while (i <= n && i <= m && f[i] == t[i]) i++ rel = "" for (k = i; k <= n; k++) rel = rel (rel == "" ? "" : "/") ".." for (k = i; k <= m; k++) rel = rel (rel == "" ? "" : "/") t[k] if (rel == "") rel = "." print rel }