[PATCH dim-tools] dim: Avoid hardcoding remote name for linux-upstream

Rodrigo Vivi rodrigo.vivi at intel.com
Tue Jul 15 20:41:33 UTC 2025


On Mon, Jul 14, 2025 at 06:50:07AM +0200, Lukas Wunner wrote:
> On Wed, Jul 09, 2025 at 09:54:02AM -0400, Rodrigo Vivi wrote:
> > On Wed, Jul 09, 2025 at 08:21:05AM +0200, Lukas Wunner wrote:
> > > On Tue, Jul 08, 2025 at 05:19:52PM -0400, Rodrigo Vivi wrote:
> > > > rdvivi at rdvivi-mobl1:~/linux/maintainer-tools$ dim blah
> > > > dim: Adding remote for linux-upstream repo from URLs: 
> > > > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> > > > https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git
> 
> This should never happen.  In function "url_to_remote", the "origin"
> remote should be discovered in this for loop:
> 
> 	for url; do
> 		remote=$(url_to_remote_from_git "$url")
> 		if [[ -n "$remote" ]]; then
> 			echo "$remote"
> 			return 0
> 		fi
> 	done
> 
> The output you've pasted above means that the for loop was unsuccessful
> in finding a remote, so function "url_to_remote" tries to add the origin
> remote, which doesn't work because it already exists.
> 
> Question is why the for loop was unsuccessful.
> 
> I note that function "url_to_remote_from_git" does this:
> 
> 	remote=$(git remote -v | grep -m 1 "$url/\? (" | cut -f 1)
> 
> Which grep version are you using?  I'm using GNU grep 3.11 and it finds
> the linux-upstream remote flawlessly.

same grep version here...

> 
> A possible error source might be the regex type.  GNU grep 3.11
> defaults to basic regular expressions.  This can be enforced with -G
> or --basic-regexp.  If you add either of these two options to the
> grep invocation, does it change behavior?
> 
> > > What does "git remote -v | grep origin" return?
> > 
> > rdvivi at rdvivi-mobl1:~/linux/drm-tip$ git remote -v | grep origin
> > origin	git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git (fetch)
> > origin	git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git (push)
> 
> That's exactly the same URL I'm using as well and "url_to_remote"
> resolves it to the remote name without any issues.
> 
> (The remote is named "torvalds" in my local repo.)

Well, this really works inside dim... For some reason the version inside dimrc
doesn't work well, but when I put a print inside dim_status function directly

echo $(repo_to_remote linux-upstream)/master 

it indeed printed out

origin/master

So, just ignore my blocker here...

> 
> Thanks,
> 
> Lukas


More information about the dim-tools mailing list