Issue 1312: Can't get relative submodule subscriptions to work
Status:  Submitted
Owner: ----
Closed:  Nov 2012
Reported by la...@lancehudson.com, Mar 29, 2012
Affected Version: 2.3-RC0

What steps will reproduce the problem?
1. Create two projects (A and B)
2. Clone project A locally
3. Create a .gitmodules file in project A
[submodule "B"]
	path = B
	url = ../B.git
	branch = refs/heads/master
4. git submodule init (to check .gitmodules created correctly)
5. git submodule update (to create gitlink)
6. Commit and push the git link and .gitmodule
7. Clone project B locally
8. make changes in project B
9. Commit changes in project B
10. pull project A
11. git submodule update
12. change is not downloaded in submodule (gitlink was not updated)

What is the expected output? What do you see instead?
The gitlink would have been updated and the changes would have shown up in the submodule dir.

Please provide any additional information below.

I also have connected to the mysql database running this and do not see a subscription in the reviewdb.submodule_subscriptions table.

Looking at the code /gerrit/gerrit-server/src/main/java/com/google/gerrit/server/util/SubmoduleSectionParser.java L84

boolean urlIsRelative = url.startsWith("/");

It looks like gerrit requires relative submodules to begin with a '/'. I have been unable to get git (msysgit 1.7.9-preview20120201) to work properly with a submodule url starting with '/' or './', only '../' works.

Before going about the patching process I want to make sure I am attempting this correctly and haven't missing anything.
Oct 25, 2012
#1 phil.hord
I had the same problem, but I didn't look in the code to see if relative URLs were already considered.  I think the "/" is definitely an error as "../" is also needed here in Linux-land.  Have you tried your patch?

In the meantime, I have this workaround which navigates through all my submodules and generates SQL statements to insert subscriptions.  I need this anyway for all my existing submodules as they are not being added as new in any case.

Here's what I used: 
INSERT INTO submodule_subscriptions VALUES ( '${SUBMODULE}' , '${BRANCH}', '${SUPERPROJECT}', '${BRANCH}', '${SUBMODULE_PATH}' );

For example,
INSERT INTO submodule_subscriptions VALUES ( 'my/submodule' , 'refs/heads/master', 'my/superproject', 'refs/heads/master', 'submodule' );"

Oct 25, 2012
#2 la...@lancehudson.com
I did try my patch at the time. Currently I do not have a running gerrit instance.
Nov 30, 2012
Project Member #4 david.pu...@sonymobile.com
(No comment was entered for this change.)
Status: Submitted
Labels: FixedIn-2.6