message: git: refactor update_submodule out of loop
diff: @@ -296,6 +296,16 @@ impl<'a> GitCheckout<'a> {
  info!("update submodules for: {:?}", repo.workdir().unwrap());
  for mut child in repo.submodules()?.into_iter() {
  + update_submodule(repo, &mut child, cargo_config).chain_error(||
  + internal(
  + format!("failed to update submodule `{}`",
  + child.name().unwrap_or("")))
  + )?;
  + }
  + Ok(())
  + }
  +
  + fn update_submodule(parent: &git2::Repository, child: &mut git2::Submodule, cargo_config: &Config) -> CargoResult<()> {
  child.init(false)?;
  let url = child.url().chain_error(|| {
  internal("non-utf8 url for submodule")
  @@ -305,7 +315,7 @@ impl<'a> GitCheckout<'a> {
  // checked out will not have a head id, so we should ignore it.
  let head = match child.head_id() {
  Some(head) => head,
  - None => continue,
  + None => return Ok(()),
  };
  // If the submodule hasn't been checked out yet, we need to
  @@ -319,12 +329,12 @@ impl<'a> GitCheckout<'a> {
  let repo = match head_and_repo {
  Ok((head, repo)) => {
  if child.head_id() == head {
  - continue
  + return Ok(())
  }
  repo
  }
  Err(..) => {
  - let path = repo.workdir().unwrap().join(child.path());
  + let path = parent.workdir().unwrap().join(child.path());
  let _ = fs::remove_dir_all(&path);
  git2::Repository::clone(url, &path)?
  }
  @@ -339,9 +349,7 @@ impl<'a> GitCheckout<'a> {
  let obj = repo.find_object(head, None)?;
  repo.reset(&obj, git2::ResetType::Hard, None)?;
  - update_submodules(&repo, cargo_config)?;
  - }
  - Ok(())
  + update_submodules(&repo, cargo_config)
  }
  }
  }
  