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

Re: [PATCH 6/6] builtin/reflog: introduce subcommand to list reflogs

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 20, 2024, 00:32 UTC
Message-ID
<xmqq7cj0ynys.fsf@gitster.g>
In-Reply-To
<cddb2de9394a07e405682e9ccdfdf5de92bb9092.1708353264.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 34 quoted lines
> diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
> index d2f5f42e67..6d8d5a253d 100755
> --- a/t/t1410-reflog.sh
> +++ b/t/t1410-reflog.sh
> @@ -436,4 +436,73 @@ test_expect_success 'empty reflog' '
>  	test_must_be_empty err
>  '
>  
> +test_expect_success 'list reflogs' '
> +	test_when_finished "rm -rf repo" &&
> +	git init repo &&
> +	(
> +		cd repo &&
> +		git reflog list >actual &&
> +		test_must_be_empty actual &&
> +
> +		test_commit A &&
> +		cat >expect <<-EOF &&
> +		HEAD
> +		refs/heads/main
> +		EOF
> +		git reflog list >actual &&
> +		test_cmp expect actual &&
> +
> +		git branch b &&
> +		cat >expect <<-EOF &&
> +		HEAD
> +		refs/heads/b
> +		refs/heads/main
> +		EOF
> +		git reflog list >actual &&
> +		test_cmp expect actual
> +	)
> +'
OK.  This is a quite boring baseline.
Show 7 quoted lines
> +test_expect_success 'reflog list returns error with additional args' '
> +	cat >expect <<-EOF &&
> +	error: list does not accept arguments: ${SQ}bogus${SQ}
> +	EOF
> +	test_must_fail git reflog list bogus 2>err &&
> +	test_cmp expect err
> +'
Makes sense.
Show 15 quoted lines
> +test_expect_success 'reflog for symref with unborn target can be listed' '
> +	test_when_finished "rm -rf repo" &&
> +	git init repo &&
> +	(
> +		cd repo &&
> +		test_commit A &&
> +		git symbolic-ref HEAD refs/heads/unborn &&
> +		cat >expect <<-EOF &&
> +		HEAD
> +		refs/heads/main
> +		EOF
> +		git reflog list >actual &&
> +		test_cmp expect actual
> +	)
> +'

Should this be under REFFILES? Ah, no, "git symbolic-ref" is valid under reftable as well, so there is no need to.

Without [5/6], would it have failed to show the reflog for HEAD?
Show 17 quoted lines
> +test_expect_success 'reflog with invalid object ID can be listed' '
> +	test_when_finished "rm -rf repo" &&
> +	git init repo &&
> +	(
> +		cd repo &&
> +		test_commit A &&
> +		test-tool ref-store main update-ref msg refs/heads/missing \
> +			$(test_oid deadbeef) "$ZERO_OID" REF_SKIP_OID_VERIFICATION &&
> +		cat >expect <<-EOF &&
> +		HEAD
> +		refs/heads/main
> +		refs/heads/missing
> +		EOF
> +		git reflog list >actual &&
> +		test_cmp expect actual
> +	)
> +'
OK.
>  test_done

It would have been "interesting" to see an example of "there is a reflog but the underlying ref for it is missing" case, but I think that falls into a minor repository corruption category, so lack of such a test is also fine.

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 16 of 39 in “reflog: introduce subcommand to list reflogs”
  1. 0/6 reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 19, 2024
  2. 1/6 dir-iterator: pass name to `prepare_next_entry_data()` directlyPatrick Steinhardt, Feb 19, 2024
  3. 2/6 dir-iterator: support iteration in sorted orderPatrick Steinhardt, Feb 19, 2024
  4. Junio C HamanoFeb 19, 2024
  5. Patrick SteinhardtFeb 20, 2024
  6. 3/6 refs/files: sort reflogs returned by the reflog iteratorPatrick Steinhardt, Feb 19, 2024
  7. Junio C HamanoFeb 20, 2024
  8. Patrick SteinhardtFeb 20, 2024
  9. 4/6 refs: drop unused params from the reflog iterator callbackPatrick Steinhardt, Feb 19, 2024
  10. Junio C HamanoFeb 20, 2024
  11. Patrick SteinhardtFeb 20, 2024
  12. 5/6 refs: stop resolving ref corresponding to reflogsPatrick Steinhardt, Feb 19, 2024
  13. Junio C HamanoFeb 20, 2024
  14. Patrick SteinhardtFeb 20, 2024
  15. 6/6 builtin/reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 19, 2024
  16. Junio C HamanoFeb 20, 2024
  17. Patrick SteinhardtFeb 20, 2024
  18. 0/7 reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 20, 2024
  19. 1/7 dir-iterator: pass name to `prepare_next_entry_data()` directlyPatrick Steinhardt, Feb 20, 2024
  20. 2/7 dir-iterator: support iteration in sorted orderPatrick Steinhardt, Feb 20, 2024
  21. 3/7 refs/files: sort reflogs returned by the reflog iteratorPatrick Steinhardt, Feb 20, 2024
  22. 4/7 refs: always treat iterators as orderedPatrick Steinhardt, Feb 20, 2024
  23. 5/7 refs: drop unused params from the reflog iterator callbackPatrick Steinhardt, Feb 20, 2024
  24. 6/7 refs: stop resolving ref corresponding to reflogsPatrick Steinhardt, Feb 20, 2024
  25. 7/7 builtin/reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 20, 2024
  26. 7/7 builtin/reflog: introduce subcommand to list reflogsTeng Long, Apr 24, 2024
  27. Patrick SteinhardtApr 24, 2024
  28. Junio C HamanoApr 24, 2024
  29. Junio C HamanoFeb 20, 2024
  30. Patrick SteinhardtFeb 21, 2024
  31. 0/8 reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 21, 2024
  32. 1/8 dir-iterator: pass name to `prepare_next_entry_data()` directlyPatrick Steinhardt, Feb 21, 2024
  33. 2/8 dir-iterator: support iteration in sorted orderPatrick Steinhardt, Feb 21, 2024
  34. 3/8 refs/files: sort reflogs returned by the reflog iteratorPatrick Steinhardt, Feb 21, 2024
  35. 4/8 refs/files: sort merged worktree and common reflogsPatrick Steinhardt, Feb 21, 2024
  36. 5/8 refs: always treat iterators as orderedPatrick Steinhardt, Feb 21, 2024
  37. 6/8 refs: drop unused params from the reflog iterator callbackPatrick Steinhardt, Feb 21, 2024
  38. 7/8 refs: stop resolving ref corresponding to reflogsPatrick Steinhardt, Feb 21, 2024
  39. 8/8 builtin/reflog: introduce subcommand to list reflogsPatrick Steinhardt, Feb 21, 2024

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.