Re: [PATCH 3/3] Teach "git branch" about --new-workdir
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- Jul 23, 2007, 05:22 UTC
- Message-ID
- <20070723052224.GF32566@spearce.org>
- In-Reply-To
- <20070723051437.GE32566@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> wrote:
Show 22 quoted lines
> Junio C Hamano <gitster@pobox.com> wrote:
> > 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.It might just be OK to refuse to lock a symlink that isn't absolute. git-new-workdir already uses absolute paths to setup the symlinks.
-- Shawn.