From e8d675c9711db9d478ae6da49c0cc5856c766d3d Mon Sep 17 00:00:00 2001 From: Jerry Zhang Date: Mon, 11 Mar 2024 12:46:30 -0700 Subject: [PATCH] amend: Add more detail to the reflog action Previously, amend had a customized reflog message, but it was static and did not have detail on which change was amended. This made looking through the reflog pretty confusing if amend was used many times. Add additional detail to show whether drop/insert was used and which commit was targeted with the amend. We don't need to show the new HEAD because this is already in the reflog. --- revup/amend.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/revup/amend.py b/revup/amend.py index ec36ee9..e29fd30 100644 --- a/revup/amend.py +++ b/revup/amend.py @@ -241,8 +241,14 @@ async def get_has_unstaged() -> bool: for stack_entry in stack: new_commit = await git_ctx.cherry_pick_from_tree(stack_entry, new_commit) + commit_details = '{}: "{}"'.format( + stack[0].commit_id[:8], stack[0].commit_msg.splitlines()[0][:40] + ) + reflog_action_str = "revup amend {}{}".format( + "--drop " if args.drop else "--insert " if args.insert else "", commit_details + ) git_env = { - "GIT_REFLOG_ACTION": "reset --soft (revup amend)", + "GIT_REFLOG_ACTION": reflog_action_str, } await git_ctx.soft_reset(new_commit, git_env) return 0