Could this

    TimeStamp deps_mtime = 0;
    if (!dep_loader_.LoadDeps(edge, &deps_mtime, err)) {
      if (!err->empty())
        return false;
      // Failed to load dependency info: rebuild to regenerate it.
      dirty = true;
    }

move to the top of this function too? Then outputs_invalid_ wouldn't be necessary, right?