From: Duy Nguyen <pclouds@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: bmwill@google.com, git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCHv7 4/6] worktree: have a function to check if worktrees are in use
Date: Fri, 9 Dec 2016 19:00:06 +0700 [thread overview]
Message-ID: <20161209120006.GA6609@ash> (raw)
In-Reply-To: <20161208210329.12919-5-sbeller@google.com>
On Thu, Dec 08, 2016 at 01:03:27PM -0800, Stefan Beller wrote:
> +/*
> + * NEEDSWORK: The values in the returned worktrees are broken, e.g.
> + * the refs or path resolution is influenced by the current repository.
> + */
> +static struct worktree **get_submodule_worktrees(const char *path, unsigned flags)
I'm ok with this (at least we know the function is half-broken). But I
wonder if we could go simpler, with something like this. It's more
efficient as well. And we can replace its implementation with
get_worktrees() or something when we are able to.
As long as this function stays in worktree.c I think it's ok for it to
peek into "worktrees" directory directly. That's what all other
functions in this file do after all.
int submodule_uses_worktrees(const char *path)
{
struct strbuf path = STRBUF_INIT;
DIR *dir;
struct dirent *d;
int ret = 0;
strbuf_addf(&path, "%s/worktrees", path);
dir = opendir(path.buf);
strbuf_release(&path);
if (!dir)
return 0;
while ((d = readdir(dir)) != NULL) {
if (is_dot_or_dotdot(d->d_name))
continue;
ret = 1;
break;
}
closedir(dir);
return ret;
}
--
Duy
next prev parent reply other threads:[~2016-12-09 12:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-08 21:03 [PATCHv7 0/6] submodule absorbgitdirs Stefan Beller
2016-12-08 21:03 ` [PATCHv7 1/6] submodule: use absolute path for computing relative path connecting Stefan Beller
2016-12-08 21:03 ` [PATCHv7 2/6] submodule helper: support super prefix Stefan Beller
2016-12-08 21:03 ` [PATCHv7 3/6] test-lib-functions.sh: teach test_commit -C <dir> Stefan Beller
2016-12-08 21:03 ` [PATCHv7 4/6] worktree: have a function to check if worktrees are in use Stefan Beller
2016-12-09 12:00 ` Duy Nguyen [this message]
2016-12-09 18:49 ` Stefan Beller
2016-12-10 11:16 ` Duy Nguyen
2016-12-08 21:03 ` [PATCHv7 5/6] move connect_work_tree_and_git_dir to dir.h Stefan Beller
2016-12-08 21:03 ` [PATCHv7 6/6] submodule: add absorb-git-dir function Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161209120006.GA6609@ash \
--to=pclouds@gmail.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.