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

Re: [PATCH 3/3] vcs_info: choose the nearest repository



Aleksandr Mezin wrote on Sun, Nov 24, 2019 at 04:14:43 +0600:
> However, this logic may not work correctly for symlinked repositories, if
> VCS_INFO_detect_* functions will continue to use :P modifier for the basedir.
> Is there a reason why :P is used for basedir instead of :a?

If ${foo} exists, then ${foo} and ${foo:P} are guaranteed to point to the same
inode.  That's not true for ${foo} and ${foo:a}.  What problem do you see with
use of :P?  Shouldn't your 3/3 patch use :P rather than :a?

> +++ b/Functions/VCS_Info/vcs_info
> @@ -117,15 +116,25 @@ vcs_info () {
>          fi
>          vcs_comm=()
>          VCS_INFO_get_cmd
> -        VCS_INFO_detect_${vcs} && (( found = 1 )) && break
> +        if VCS_INFO_detect_${vcs}; then
> +            if (( ${#vcs_comm[basedir]:a} > ${#nearest_vcs_comm[basedir]:a} )); then

If $vcs_comm[basedir] is /foobar and $nearest_vcs_comm[basedir] is /foo, the
condition would be true but there'd be no parent dir–subdir relationship
between the two values.

> +                nearest_vcs_comm=("${(kv)vcs_comm[@]}")
> +                nearest_vcs="${vcs}"
> +                nearest_backend_misc=("${(kv)backend_misc[@]}")
> +            fi
> +        fi
>      done

Cheers,

Daniel



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