git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/2] rebase: find --fork-point with full refgg

From
Denton Liu <liu.denton@gmail.com>
Date
Dec 6, 2019, 19:11 UTC
Message-ID
<20191206191147.GA16379@generichostname>
In-Reply-To
<CANmPhj38UqZiePEPbPJBwUTOEJrfA6j3aP8KBHvAY6EA-J7Nsw@mail.gmail.com>
Hi Alex,
On Fri, Dec 06, 2019 at 08:46:29AM -0500, Alex Torok wrote:
Show 28 quoted lines
> Thank you for the feedback Denton & Phillip!
> 
> On Fri, Dec 6, 2019 at 5:52 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
> > On 06/12/2019 01:48, Denton Liu wrote:
> > > nit: * should be attached to the variable name.
> >
> > I think you also need to free it once you've called get_fork_point() as
> > well.
> 
> Yup. Got it.
> 
> > On 06/12/2019 01:48, Denton Liu wrote:
> > >
> > >> +            dwim_ref_or_die(options.upstream_name, strlen(options.upstream_name), &full_name);
> > >
> > > Also, thinking about this more, would it be possible to put the dwim_ref
> > > logic into get_fork_point() directly? There are currently only these two
> > > callers so I suspect it should be fine and it'll result in cleaner
> > > logic.
> >
> > If you do that then it would be better to use error() rather than die()
> > in get_fork_point() and return an error to the caller as we try to avoid
> > adding code to libgit that dies. This lets the caller handle any cleanup
> > that they need to before exiting.
> 
> Would the signature of get_fork_point change to be something like:
> int get_fork_point(const char *refname, struct commit *commit,
>    struct commit **fork_point, struct strbuf *err)

I would drop the last parameter. If an error is detected, you could just do

	return error(_("oh no, something bad happened"));

Even though we try and avoid dying in the middle of libgit, we print errors out very often so it should be fine here.

Show 20 quoted lines
> > > Also, I'm not why this test case in particular that was duplicated (and
> > > not the one above) given that the first three `--fork-point` test cases
> > > fail without the change to rebase. Perhaps we want to duplicate all
> > > "refs/heads/master" tests with a corresponding "master" test?
> 
> I only duplicated one so that there would only be one test case that
> would fail if a regression around getting the fork point with a short
> ref name was introduced.
> 
> I just happened to pick that one because it was closest to the rebase
> command I was running when I found the bug :)
> 
> I can include some of the above reasoning in the commit message.
> Alternatively:
> * I could duplicate all of tests
> * I could change all of the tests to use the short ref name
> 
> I'm leaning towards just leaving one test (maybe with a comment?)
> for the short ref name --fork-point so that there is more resolution
> around where a bug could be on test failure.

I would just duplicate all of the tests. When the tests are pretty cheap to run (as they are in this case), I tend to err on the side of adding more tests since they might catch more odd edge-cases but, in this case, all of the fork point logic goes through one common block so the duplicate logic doesn't really buy us anything.

I'm pretty impartial so I'll leave it up to you ;)
Thanks,
Denton
> 
> Let me know what you think,
> Alex
Previous: Alex TorokNext: Phillip Wood
Message 15 of 23 in “rebase: fix bug in --fork-point”
  1. 0/3 rebase: fix bug in --fork-pointAlex Torok, Dec 5, 2019
  2. 1/3 rebase: add test for rebase --fork-point with short upstreamAlex Torok, Dec 5, 2019
  3. Junio C HamanoDec 5, 2019
  4. Alex TorokDec 5, 2019
  5. 2/3 rebase: refactor dwim_ref_or_die from merge-base.cAlex Torok, Dec 5, 2019
  6. 3/3 rebase: fix rebase to use full ref to find fork-pointAlex Torok, Dec 5, 2019
  7. 0/2 rebase: fix bug in --fork-pointAlex Torok, Dec 5, 2019
  8. 1/2 rebase: refactor dwim_ref_or_die from merge-base.cAlex Torok, Dec 5, 2019
  9. Denton LiuDec 6, 2019
  10. Alex TorokDec 6, 2019
  11. 2/2 rebase: find --fork-point with full refAlex Torok, Dec 5, 2019
  12. Denton LiuDec 6, 2019
  13. Phillip WoodDec 6, 2019
  14. Alex TorokDec 6, 2019
  15. Denton LiuDec 6, 2019
  16. Phillip WoodDec 6, 2019
  17. 0/1 rebase: fix --fork-point with short ref upstreamAlex Torok, Dec 9, 2019
  18. 1/1 rebase: fix --fork-point with short refnameAlex Torok, Dec 9, 2019
  19. Junio C HamanoDec 9, 2019
  20. Alex TorokDec 11, 2019
  21. Denton LiuDec 11, 2019
  22. Eric SunshineDec 11, 2019
  23. Junio C HamanoFeb 11, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.