Peel onions and garlic. Cut onions into rings, chop garlic finely. Wash thyme, shake dry and chop finely. Heat oil in a pot.
Stew onions and garlic in it at low heat for about 10 minutes until soft, without browning. Add about 2/3 of the thyme and braise briefly. Deglaze with stock, vinegar and wine, season with salt, pepper and sugar. Simmer covered soup for about 15 minutes.
Roughly pluck the bread. Grate cheese. Pour the soup into 4 ovenproof moulds, spread the bread on top and generously sprinkle the cheese on top. Bake in a preheated oven (electric cooker: 225 °C/ convection oven: 200 °C/ gas: see manufacturer) for 5-7 minutes. Remove soup carefully from the oven and serve.