Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PATCH 6/5] Fix parsing of @{-1}@{1}

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:45:58

Hi,

On Sat, 17 Jan 2009, Junio C Hamano wrote:
Johannes Schindelin [off-list ref] writes:
quoted
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 <redacted>
---

	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help