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



Bart Schaefer wrote on Mon, Nov 25, 2019 at 01:13:21 -0800:
> I have several directories that are BOTH git and CVS repositories, used for
> keeping two different origins in sync.
> 
> This is admittedly an unusual situation -- we have a legacy process that
> expects to fetch sources from CVS, and developers collaborating through git
> -- but I would be annoyed if vcs didn't find the git data because of the
> CVS subdir.

Doesn't my proposal address this?  In my proposal, if {foo,foo/bar,foo/bar/baz}/CVS
and foo/bar/.git all exist, and cwd is foo/bar/baz/, git info would be shown
because the git root, foo/bar/, is closer (deeper) than the CVS root, foo/ —
notwithstanding that foo/bar/baz/CVS exists.

To be self-contained, what I proposed is:

- If [[ ${basedirA:P} == ${basedirB:P}/* ]], show ${basedirA}'s info.
- If [[ ${basedirB:P} == ${basedirA:P}/* ]], show ${basedirB}'s info.
- Show the info for whichever VCS is listed first in the 'enable' style.

Would that DTRT in your use-case?

> I would expect the list of repo types in the "enable" style to be handled
> in the order they appear.

Do you mean, that if the enable style lists "git" ahead of "cvs", then vcs_info
would always look for git info first and only show CVS info if git wasn't
detected?  If so, see above.

Or do you mean, show _both_ the CVS and git info?  I don't see how that would
work.  Consider:

zstyle ':vcs_info:git:default:*'     formats foo1
zstyle ':vcs_info:git:default:lorem' formats foo2 bar2
zstyle ':vcs_info:cvs:default:*'     formats baz
precmd() { vcs_info default; [[ -z $vcs_info_msg_1_ ]] && print -Pr -- $vcs_info_msg_1_ }

Would this print "bar2" or "baz"?  How could the precmd function determine
where the git info ends and the cvs info begins?

Perhaps we could have vcs_info return multiple arrays rather than multiple
scalars.  For example, «typeset -a vcs_info_set_1_» could contain git info and
«typeset -a vcs_info_set_2_» could contain cvs info.  That would also address
the case about git-within-git or hg-within-hg that I mentioned earlier.
However, it begs the question, why does vcs_info today use multiple scalars
rather than a single array?

Cheers,

Daniel



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