"Shawn O. Pearce" <spearce@xxxxxxxxxxx> writes: > I live by new-workdir. I do everything with it. And today I just > spent over an hour sorting out cases where my many, many workdirs > have different refs than their base repositories, because their > packed-refs files are different. Grrrrrrrrrrrrrrrrrr. > > So we really need to make anyone that edits packed-refs (and > maybe also config) resolve the symlink and do the edit in the > target directory. Then we can consider adding this workdir thing > to core git. This is actually not limited to packed-refs file, but applies to other things as well. I have been wondering if something like this patch would be sufficient. The idea essentially is to take the lock on the link target when we try to take a lock on something that is a symlink pointing elsewhere. --- lockfile.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/lockfile.c b/lockfile.c index fb8f13b..7fc71d9 100644 --- a/lockfile.c +++ b/lockfile.c @@ -28,6 +28,17 @@ static void remove_lock_file_on_signal(int signo) static int lock_file(struct lock_file *lk, const char *path) { int fd; + struct stat st; + + if ((!lstat(path, &st)) && S_ISLNK(st.st_mode)) { + ssize_t sz; + static char target[PATH_MAX]; + sz = readlink(path, target, sizeof(target)); + if (sz < 0) + warning("Cannot readlink %s", path); + else + path = target; + } sprintf(lk->filename, "%s.lock", path); fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666); if (0 <= fd) { - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html