Heat the oil for 1 minute over moderate heat in a heavy 12-inch skillet with a heat-proof handle. Add the potatoes, rosemary, and pepper and toss well to mix. Cover snugly with aluminum foil, transfer to the oven and bake 30 minutes. Remove from the oven, discard the foil, and add the onions, garlic, and salt. Stir well, return to the oven, and bake uncovered for 15 minutes, stirring every 5 minutes until the onions are brown. Serve at once.