Skip to content

Commit

Permalink
amend: Allow amending with pure renames
Browse files Browse the repository at this point in the history
If the only staged changes are pure renames, 'git diff --cached
--quiet' will not report any changes. As a result, attempting to
'revup amend' would skip writing a new tree for the commit and the
rename would still be staged rather than added to the amended commit.

Fix this by turning off rename detection when checking for staged
changes in 'revup amend'. This should be slightly more efficient as
well.

Signed-off-by: Brian Kubisiak <[email protected]>
  • Loading branch information
velentr authored and jerry-skydio committed Nov 5, 2024
1 parent 56dbea6 commit 22f331e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions revup/amend.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ async def main(args: argparse.Namespace, git_ctx: git.Git) -> int:
"""

async def get_has_unstaged() -> bool:
return args.all and await git_ctx.git_return_code("diff", "--quiet") != 0
return args.all and await git_ctx.git_return_code("diff", "--no-renames", "--quiet") != 0

has_staged, has_unstaged = await asyncio.gather(
git_ctx.git_return_code("diff", "--cached", "--quiet"),
git_ctx.git_return_code("diff", "--cached", "--no-renames", "--quiet"),
get_has_unstaged(),
)

Expand Down

0 comments on commit 22f331e

Please sign in to comment.