Show 33 quoted lines
> Well, I would rather be in favor of something like this.
>
> -- >8 --
> Subject: interpret_nth_last_branch(): avoid traversing the reflog twice
>
> You can have quite a many reflog entries, but you typically won't recall
> which branch you were on after switching branches for more than several
> times.
>
> Instead of reading the reflog twice, this reads the branch switching event
> and keeps the latest 16 (which is an arbitrary limitation that should be
> plenty) such entry, to switch back to the branch we were recently on.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> sha1_name.c | 48 +++++++++++++++++++++------------------------
> t/t2012-checkout-last.sh | 44 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 66 insertions(+), 26 deletions(-)
>
> diff --git a/sha1_name.c b/sha1_name.c
> index 9e1538e..d6622f2 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -750,19 +746,19 @@ int interpret_nth_last_branch(const char *name, struct strbuf *buf)
> nth = strtol(name+3, &num_end, 10);
> if (num_end != brace)
> return -1;
> ...
> - if (cb.nth < nth)
> - return 0;
> ...
> + if (cb.cnt < nth)
> + return -1;