For negative potential, the diode becomes reverse biased whereas for positive potential diode is forward biased.
For $V_i<0$, the diode is reverse biased and hence offer infinite resistance, so circut would be like as shown in Fig. (2) and $V_0=0$
For $V_i > 0$, the diode is forward biased and circuit would be as shown in Fig. (3) and $V_0=V_i$.