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

Re: [PATCH 2/3] update-ref: pass reflog message argument to delete_refs

From
Jeff King <peff@peff.net>
Date
Feb 17, 2017, 08:22 UTC
Message-ID
<20170217082253.kxjezkxfqkfxjhzr@sigill.intra.peff.net>
In-Reply-To
<20170217035800.13214-3-kyle@kyleam.com>
On Thu, Feb 16, 2017 at 10:57:59PM -0500, Kyle Meyer wrote:
Show 5 quoted lines
> Now that delete_refs() accepts a reflog message, pass the
> user-provided message to delete_refs() rather than silently dropping
> it.  The doesn't matter for the deleted ref's log because the log is
> deleted along with the ref, but this entry will show up in HEAD's
> reflog when deleting a checked out branch.
Sounds good.
Show 10 quoted lines
> diff --git a/builtin/update-ref.c b/builtin/update-ref.c
> index a41f9adf1..f642acc22 100644
> --- a/builtin/update-ref.c
> +++ b/builtin/update-ref.c
> @@ -435,7 +435,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
>  		 */
>  		return delete_ref(refname,
>  				  (oldval && !is_null_sha1(oldsha1)) ? oldsha1 : NULL,
> -				  flags, NULL);
> +				  flags, msg);
This looks obviously correct.
Show 16 quoted lines
> diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
> index b0ffc0b57..65918d984 100755
> --- a/t/t1400-update-ref.sh
> +++ b/t/t1400-update-ref.sh
> @@ -85,6 +85,15 @@ test_expect_success "delete $m (by HEAD)" '
>  '
>  rm -f .git/$m
>  
> +test_expect_success "deleting current branch adds message to HEAD's log" '
> +	git update-ref $m $A &&
> +	git symbolic-ref HEAD $m &&
> +	git update-ref -mdelmsg -d $m &&
> +	! test -f .git/$m &&
> +	grep "delmsg$" .git/logs/HEAD >/dev/null
> +'
> +rm -f .git/$m
I think covering this with a test is good.

I don't know if it's also worth testing that deleting via HEAD also writes the reflog. I.e.,:

  git update-ref -m delete-by-head -d HEAD

Some of the style here is a bit out-dated, but I think you are just matching the surrounding tests. So that's OK by me (though a patch to modernize the whole thing would be welcome, too).

For reference, the two things I notice are:
  - we prefer test_path_is_missing to "! test -f" these days.
  - we don't redirect the output of grep (it's handled already in
    non-verbose mode, and in verbose mode we try to be...verbose).
-Peff
Previous: Kyle MeyerNext: Junio C Hamano
Message 11 of 36 in “HEAD's reflog entry for a renamed branch”
  1. Kyle MeyerJan 16, 2017
  2. Jeff KingJan 26, 2017
  3. Junio C HamanoJan 26, 2017
  4. Jeff KingJan 26, 2017
  5. 0/3 delete_ref(): support reflog messagesKyle Meyer, Feb 17, 2017
  6. 1/3 delete_refs(): accept a reflog message argumentKyle Meyer, Feb 17, 2017
  7. Jeff KingFeb 17, 2017
  8. Junio C HamanoFeb 17, 2017
  9. Kyle MeyerFeb 17, 2017
  10. 2/3 update-ref: pass reflog message argument to delete_refsKyle Meyer, Feb 17, 2017
  11. Jeff KingFeb 17, 2017
  12. Junio C HamanoFeb 17, 2017
  13. Kyle MeyerFeb 17, 2017
  14. Jeff KingFeb 17, 2017
  15. 3/3 rename_ref: replace empty deletion message in HEAD's logKyle Meyer, Feb 17, 2017
  16. Jeff KingFeb 17, 2017
  17. Junio C HamanoFeb 17, 2017
  18. Jeff KingFeb 17, 2017
  19. Jeff KingFeb 17, 2017
  20. Junio C HamanoFeb 17, 2017
  21. Kyle MeyerFeb 17, 2017
  22. Kyle MeyerFeb 17, 2017
  23. Jeff KingFeb 17, 2017
  24. Junio C HamanoFeb 17, 2017
  25. Jeff KingFeb 17, 2017
  26. 0/4 delete_ref: support reflog messagesKyle Meyer, Feb 21, 2017
  27. 1/4 delete_ref: accept a reflog message argumentKyle Meyer, Feb 21, 2017
  28. Duy NguyenFeb 23, 2017
  29. Junio C HamanoFeb 23, 2017
  30. Kyle MeyerFeb 25, 2017
  31. 2/4 update-ref: pass reflog message to delete_ref()Kyle Meyer, Feb 21, 2017
  32. 4/4 branch: record creation of renamed branch in HEAD's logKyle Meyer, Feb 21, 2017
  33. 3/4 rename_ref: replace empty message in HEAD's logKyle Meyer, Feb 21, 2017
  34. Jeff KingFeb 21, 2017
  35. Junio C HamanoFeb 21, 2017
  36. Kyle MeyerFeb 21, 2017

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.