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

Re: [PATCH v5 1/1] contrib/subtree: Add a test for subtree rebase that loses commits

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 19, 2016, 17:41 UTC
Message-ID
<xmqqsi1tbh68.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<3eb25268597083cdb10303e3d5790302e719a803.1453172369.git.greened@obbligato.org>
David Greene <greened@obbligato.org> writes:
Show 19 quoted lines
> From: David A. Greene <greened@obbligato.org>
>
> This test merges an external tree in as a subtree, makes some commits
> on top of it and splits it back out.  In the process the added commits
> are lost or the rebase aborts with an internal error.  The tests are
> marked to expect failure so that we don't forget to fix it.
>
> Signed-off-by: David A. Greene <greened@obbligato.org>
> ---
>
> Notes:
>     Change History:
>     
>     v1 - Initial version
>     v2 - Additional tests and code cleanup
>     v3 - Remove check_equal, mark comments on failure and remove
>          test_debug statements
>     v4 - Send correct v3 test (botched v3)
>     v5 - Fix use of verbose
Thanks, both.  Will queue.
I have a couple of questions and comments, though.
Show 7 quoted lines
> +test_expect_success 'setup' '
> +	test_commit README &&
> +...
> +	tree=$(git write-tree) &&
> +	head=$(git rev-parse HEAD) &&
> +	rev=$(git rev-parse --verify files-master^0) &&
> +	commit=$(git commit-tree -p $head -p $rev -m "Add subproject master" $tree) &&

I think at this point, your index and working tree states match that of $commit. So the next command ...

> +	git reset $commit &&

... made me wonder what its significance was. I think you are doing this solely to move the HEAD pointer to point at $commit, but then it would be much better and more readable to use update-ref, i.e. making this line to:

	git update-ref HEAD $commit &&

instead, as "write-tree && commit-tree && update-ref" is a familiar pattern to reimplement "git commit" using the plumbing. Ending that three-command sequence with "reset" breaks the pattern.

Show 5 quoted lines
> +	(
> +		cd files_subtree &&
> +		test_commit master4
> +	) &&
> +	test_commit files_subtree/master5

I understand that you are creating these two commits both in the top-level repository (the one the history initially created in "files" repository gets merged into), but you are creating them slightly differently. Is that significant? I am not complaining about the style of writing tests, but I am wondering if having these two commits created differently has any effect on the bug you observed, which may be a good starting point for anybody who wants to fix it to start digging from. IOW, would the resulting history different if you did this instead?

	test_commit files_subtree/master4 &&
	test_commit files_subtree/master5

I also notice that files_subtree/master4 does not appear in any of the verification in the three tests that use the history being prepared here, i.e. if master4 is silently dropped while master5 is kept, such a bug won't be caught by them.

Previous: Eric SunshineNext: David A. Greene
Message 20 of 24 in “Test rebase -Xsubtree”
  1. Test rebase -XsubtreeDavid Greene, Jan 5, 2016
  2. Add a test for subtree rebase that loses commitsDavid Greene, Jan 5, 2016
  3. Torsten BögershausenJan 5, 2016
  4. Dennis KaarsemakerJan 5, 2016
  5. Torsten BögershausenJan 5, 2016
  6. Eric SunshineJan 5, 2016
  7. David A. GreeneJan 5, 2016
  8. Test rebase -XsubtreeDavid Greene, Jan 10, 2016
  9. Add a test for subtree rebase that loses commitsDavid Greene, Jan 10, 2016
  10. Eric SunshineJan 15, 2016
  11. David A. GreeneJan 17, 2016
  12. 1/1 Add a test for subtree rebase that loses commitsDavid Greene, Jan 17, 2016
  13. Eric SunshineJan 17, 2016
  14. David A. GreeneJan 17, 2016
  15. 1/1 contrib/subtree: Add a test for subtree rebase that loses commitsDavid Greene, Jan 17, 2016
  16. Eric SunshineJan 18, 2016
  17. David A. GreeneJan 19, 2016
  18. 1/1 contrib/subtree: Add a test for subtree rebase that loses commitsDavid Greene, Jan 19, 2016
  19. Eric SunshineJan 19, 2016
  20. Junio C HamanoJan 19, 2016
  21. David A. GreeneJan 20, 2016
  22. Junio C HamanoApr 12, 2016
  23. David A. GreeneJun 28, 2016
  24. 1/1 contrib/subtree: Add a test for subtree rebase that loses commitsDavid Greene, Jun 28, 2016

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.