Re: [PATCH 6/5] Fix parsing of @{-1}@{1}
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 17, 2009, 21:22 UTC
- Message-ID
- <alpine.DEB.1.00.0901172214120.3586@pacific.mpi-cbg.de>
- In-Reply-To
- <7vsknh66qu.fsf@gitster.siamese.dyndns.org>
Hi,
On Sat, 17 Jan 2009, Junio C Hamano wrote:
Show 18 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > To do that, Git no longer looks forward for the '@{' corresponding to the
> > closing '}' but backward, and dwim_ref() as well as dwim_log() learnt
> > about the @{-<N>} notation.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> >
> > The modifications of dwim_ref() and dwim_log() are probably
> > more important than the issue I tried to fix...
>
> Good, so we can say things like:
>
> git log -g @{-1}
> git show-branch -g @{-1}
>
> with this?I _hope_ :-)
> By the way, I noticed that without these patch series we show something
> when "git rev-parse --verify @{-1}" is asked for. What is it trying to
> show?Apparently the same as @{1.Jan}: in get_sha1_basic(), we have this code: /* Is it asking for N-th entry, or approxidate? */
for (i = nth = 0; 0 <= nth && i < reflog_len; i++) {
char ch = str[at+2+i];
if ('0' <= ch && ch <= '9')
nth = nth * 10 + ch - '0';
else
nth = -1;
}
if (100000000 <= nth) {
at_time = nth;
nth = -1;
} else if (0 <= nth)
at_time = 0;
else {
char *tmp = xstrndup(str + at + 2, reflog_len);
at_time = approxidate(tmp);
free(tmp);
}So in the loop, nth is set to -1 because of a non-digit, and later, approxidate is called for nth == -1, which does this:
$ ./test-date now now -> bad -> Thu Jan 1 01:00:00 1970 now -> Sat Jan 17 22:21:20 2009
Ciao, Dscho