# Re: \[PATCH\] rebase: use reflog to find common base with upstream

- From: Junio C Hamano \<hidden\>
- Date: 2016-06-15 22:59:04 
- List: git
- Page: https://ratatoskr.run/git/2016/06/7615378
- Thread: https://ratatoskr.run/git/2016/06/7615033/t.md

```text
Martin von Zweigbergk [ref] writes:

> I think
>
>   git merge-base HEAD $(git rev-list -g "$upstream_name")
>
> is roughly correct and hopefully fast enough. That can lead to too
> long a command line, so I was planning on teaching merge-base a
> --stdin option, but never got around to it.

Sorry for coming in late.

I think the above with s/HEAD/$curr_branch/ is a good way to compute
what the whole "for reflog in $(git rev-list -g $remoteref" loop
computes when one of the historic tips recorded in the reflog was
where $curr_branch forked from, i.e. the loop actually finds at
least one ancestor in the reflog and breaks out after setting
oldremoteref.  But it would give a completely different commit if
none of the reflog entries is a fork point.

A two patch series forthcoming.
```
