Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH 2/3] vcs_info/cvs: set vcs_comm[basedir] in VCS_INFO_detect_cvs



Aleksandr Mezin wrote on Mon, 25 Nov 2019 07:31 +00:00:
> On Mon, Nov 25, 2019 at 10:35 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> >
> > Aleksandr Mezin wrote on Sun, Nov 24, 2019 at 04:14:42 +0600:
> > > +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs
> > > @@ -5,11 +5,7 @@
> > > -cvsbase="."
> > > -while [[ -d "${cvsbase}/../CVS" ]]; do
> > > -    cvsbase="${cvsbase}/.."
> > > -done
> > > +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_cvs
> > > @@ -7,5 +7,12 @@ setopt localoptions NO_shwordsplit
> > > +local cvsbase="."
> > > +while [[ -d "${cvsbase}/../CVS" ]]; do
> > > +    cvsbase="${cvsbase}/.."
> > > +done
> >
> > I know you just moved this code around, but I'd like to point out that it
> > causes an infinite loop when /CVS exists.
> 
> Also I probably shouldn't have moved the code in the first place. If
> the current directory has `CVS/Repository` in it, it means that the
> directory is controlled by CVS, and maybe we shouldn't consider .git
> from the parent directory (even when the parent directory also has
> `CVS/Repository` in it). Though it's questionable.
> 
> Example:
> ~/cvs-dir/CVS/Repository
> ~/cvs-dir/git-repo/.git
> ~/cvs-dir/git-repo/CVS/Repository
> ~/cvs-dir/git-repo/cvs-subdir/CVS/Repository
> 
> I'm not sure what vcs_info should output for ~/cvs-dir/git-repo/cvs-subdir/

How about showing the information from the worktree whose root is deeper
(= closer to cwd)?  Users can show the information for the other worktree
by setting the 'enable' style in a :vcs_info:foo:* context and calling
«vcs_info foo».

I see two possible problems:

One, the workaround isn't sufficient when the two worktrees are of the
same VCS (for example, git and git, as opposed to git and CVS) — that
is, when foo/.$vcs and foo/bar/.$vcs both exist as separate, nested
worktrees.  However, this use-case isn't well-supported by all
VCS's.  For example, which worktree «cd foo && $vcs add bar/baz» will
take effect in is anyone's guess.

Two, as I pointed out in reply to an offlist response, the existence of
$GIT_DIR and $GIT_WORK_TREE means that the two VCS's basedirs need not
be in a parent dir – subdir relationship with each other; they can be
/foo/bar and /foo/baz.  At that point, we won't be able to use worktree
root paths as discriminators.  Re-reading PEP 20, I think "Information will be
shown for whichever VCS is listed first in the 'enable' style" might be a sensible
design… but it's a puzzler.

Cheers,

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author