Skip to content

Commit

Permalink
Reference the .gitmodules file to get a list of current submodules, r…
Browse files Browse the repository at this point in the history
…ather than the .git/config file, which may have old submodules from other branches. JENKINS-37419
  • Loading branch information
courtarro committed Dec 5, 2016
1 parent 140e8f0 commit 28db63d
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -961,6 +961,10 @@ public SubmoduleUpdateCommand timeout(Integer timeout) {
* @throws InterruptedException if called methods throw same exception
*/
public void execute() throws GitException, InterruptedException {
// Initialize the submodules to ensure that the git config
// contains the URLs from .gitmodules.
submoduleInit();

This comment has been minimized.

Copy link
@darxriggs

darxriggs Jul 25, 2018

Contributor

@MarkEWaite

  1. Do you know why --init is still used in line 971 now when an explicit init is added here?

  2. Should submoduleInit() also be called in JGitAPIImpl's implementation of SubmoduleUpdateCommand::execute()?

I am asking because after your upgrade to JGit 5.0.1, I was having a look if some tests annoted with @NotImplementedInJGit could be enabled for JGit. Some tests (for example this one) just call submoduleUpdate() without submoduleInit(). So the CliGit implementation runs successfully but the JGit implementation doesn't.

If you tell me to either add submoduleInit() to tests where it is missing or to JGit's submoduleUpdate() I will try to prepare a pull request with more tests enabled for JGit. It looks like it now supports renamed submodules.

This comment has been minimized.

Copy link
@MarkEWaite

MarkEWaite Jul 25, 2018

Contributor

As far as I can tell, the --init is used with --recursive to assure that all the submodules are initialized (recursively).

Since the submoduleInit() is called in the command line git implementation, it seems very reasonable to also make that same call in the JGit implementation.

I'd rather not have the submoduleInit() added to the tests, since I think it is better to insert that into the JGitAPIImpl.


ArgumentListBuilder args = new ArgumentListBuilder();
args.add("submodule", "update");
if (recursive) {
Expand Down Expand Up @@ -995,7 +999,7 @@ else if (!referencePath.isDirectory())
try {
// We might fail if we have no modules, so catch this
// exception and just return.
cfgOutput = launchCommand("config", "--get-regexp", "^submodule");
cfgOutput = launchCommand("config", "-f", ".gitmodules", "--get-regexp", "^submodule\\.(.*)\\.url");
} catch (GitException e) {
listener.error("No submodules found.");
return;
Expand Down

0 comments on commit 28db63d

Please sign in to comment.