Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop in IceGitLocalRepositoryType if the path is wrong #839

Closed
gcotelli opened this issue Jun 8, 2018 · 0 comments
Closed

Infinite loop in IceGitLocalRepositoryType if the path is wrong #839

gcotelli opened this issue Jun 8, 2018 · 0 comments
Milestone

Comments

@gcotelli
Copy link
Contributor

gcotelli commented Jun 8, 2018

I've just realized that if you try to load a project and choose a wrong path for the repo, so it never encounter the .git folder, at least on Unix when it reaches / it keeps looping because parent returns itself.
This is the offending method:

splitRootAndSubdirectoryFromLocation
	| root subDir |

	(self location beginsWith: (self class type, '://'))
		ifFalse: [ self error: 'Invalid URL (It should be ', self class type, '://...)' ].
	root := (self location allButFirst: self class type size + 3) asFileReference.
	subDir := #().
	[ root isNil or: [ self isGitRoot: root ] ] 
	whileFalse: [ 
		(root asAbsolute = FileSystem workingDirectory)
			ifFalse: [ subDir := subDir copyWithFirst: root basename ].
		root := root parent ].
	root ifNil: [ self error: 'I can''t find a .git/config file.' ].
	
	^ { 
		root. "a FileReference"
		String streamContents: [ :stream | subDir asStringOn: stream delimiter: '/' ] "a String" }

For example if you execute in a Playground:

Metacello new
		baseline: 'Grease';
		repository: ('gitlocal:///home/Grease/repository' );
		lock.

it seems that nothing is happening, but if you stop the process it's just looping, because [ root isNil or: [ self isGitRoot: root ] ] it's never true when / is reached.

Image
-----
/home/gcotelli/Pharo/7.0-64bits/Pharo.image
Pharo7.0alpha
Build information: Pharo-7.0+alpha.build.1025.sha.d43e3073c4b005c606c5436e4220617108bb841a (64 Bit)
Unnamed

Virtual Machine
---------------
/home/gcotelli/Pharo/7.0-64bits/pharo-vm/lib/pharo/5.0-201805090836/pharo
CoInterpreter VMMaker.oscog-eem.2380 uuid: c76d37e1-445c-4e34-9796-fc836dfd50c9 May  9 2018
StackToRegisterMappingCogit VMMaker.oscog-eem.2380 uuid: c76d37e1-445c-4e34-9796-fc836dfd50c9 May  9 2018
VM: 201805090836 https://github.com/OpenSmalltalk/opensmalltalk-vm.git Date: Wed May 9 10:36:12 2018 CommitHash: 334be97 Plugins: 201805090836 https://github.com/OpenSmalltalk/opensmalltalk-vm.git

Unix built on May  9 2018 08:54:13 Compiler: 4.8.4
VMMaker versionString VM: 201805090836 https://github.com/OpenSmalltalk/opensmalltalk-vm.git Date: Wed May 9 10:36:12 2018 CommitHash: 334be97 Plugins: 201805090836 https://github.com/OpenSmalltalk/opensmalltalk-vm.git
CoInterpreter VMMaker.oscog-eem.2380 uuid: c76d37e1-445c-4e34-9796-fc836dfd50c9 May  9 2018
StackToRegisterMappingCogit VMMaker.oscog-eem.2380 uuid: c76d37e1-445c-4e34-9796-fc836dfd50c9 May  9 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants