Sec. 3. If a defendant appeals his conviction, is not released on bail, and is retained in a jail as provided in Section 7, Article 42.09, pending his appeal, the judge of the court in which the defendant was convicted shall give the defendant credit on his sentence for the time that the defendant has spent in jail pending disposition of his appeal. The court shall endorse on both the commitment and the mandate from the appellate court all credit given the defendant under this section, and the Texas Department of Criminal Justice shall grant the credit in computing the defendant's eligibility for parole and discharge.