We study the effect of a passive harmonic cavity, introduced to cause bunch lengthening, in an electron storage ring. We derive a formula for the induced voltage from such a cavity with high Q, excited by a sequence of bunches, allowing for arbitrary gaps in the sequence and arbitrary currents. Except for a minor term that can be determined iteratively, the voltage is given in terms of a single mode of the Fourier transforms of the bunch forms, namely, the mode at the resonant frequency of the cavity. Supposing that the only wakefield is from the harmonic cavity, we derive a system of coupled Haïssinski equations which determine the bunch positions and profiles in the equilibrium state. The number of unknowns in the system is only twice the number of bunches, and it can be solved quickly by a Newton iteration, starting with a guess determined by path following from a solution at a weak current. We explore the effect of the fill pattern on the bunch lengthening and also the dependence on the shunt impedance and detuning of the cavity away from the third harmonic of the main accelerating cavity. We consider two measures to reduce the effects of gaps: (i) distribution of the gaps around the ring to the greatest extent allowed and (ii) "guard bunches"with higher charges adjacent to the gaps, compensating for the charge missing in gaps. Results for parameters of the forthcoming Advanced Light Source upgrade are presented.