Skip to content
Snippets Groups Projects
Commit 35591fb8 authored by Lucas De Marchi's avatar Lucas De Marchi Committed by Lucas De Marchi
Browse files

dim: Fix substring match

When checking if a url matches one of the urls from the drm_tip_repos
array, commit faa12d34 ("dim_setup: Use "repo" for remote default
name") used a substring match. However, it's possible that a url is a
substring of another, leading to the wrong repo being returned.

Depending on the order of iteration in the drm_tip_repo array,
ssh://git.freedesktop.org/git/drm/drm would match as a substring
of ssh://git.freedesktop.org/git/drm/drm-intel, thus returning drm-intel
rather than drm as repo.

It doesn't always fail because Bash doesn't guarantee the order of
associative arrays. Running with Bash 5.2.15 it works, because it
compares drm's url before drm-intel's. However it was reported that
with 5.0.17 it doesn't follow the same order, and thus causing this
issue.

On a dim setup execution, it errors out like this:

	dim: No git remote for any of the URLs ssh://git.freedesktop.org/git/drm/drm git://anongit.freedesktop.org/drm/drm https://anongit.freedesktop.org/git/drm/drm https://anongit.freedesktop.org/git/drm/drm.git

 found in /path/to/src
	Enter a name to auto-add this remote, leave blank to abort: drm-intel
	error: remote drm-intel already exists.

Also, dim should probably start using `set -e`, because the error above
is ignored and in the end it shows:

	dim setup successfully completed!

Leaving a half-baked setup.

Reported-by: default avatarJohn Harrison <john.c.harrison@intel.com>
Fixes: faa12d34 ("dim_setup: Use "repo" for remote default name")
Signed-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
parent 2d919ac6
No related branches found
No related tags found
1 merge request!30dim: Fix substring match
Pipeline #1089854 passed
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment