Junio C Hamano <gitster@xxxxxxxxx> wrote: > "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. Yes, but most other things aren't symlinks, they are in symlinked directories. But better to cover it in a single location and have it Just Work(tm) then to special case things. > 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) { Right. But don't you have to resolve target relative to path? If the symlink is an absolute path its fine as-is, but if it was relative its relative to path, not pwd. -- Shawn. - 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