arxanas / git-branchless

High-velocity, monorepo-scale workflow for Git
Apache License 2.0
3.37k stars 80 forks source link

"git amend" commits all changes, not just staged changes #1340

Closed talios closed 3 weeks ago

talios commented 3 weeks ago

Description of the bug

Currently, when you run git record branchless will commit all changes UNLESS some changes have already been staged - then only those get committed.

It would be good to see git amend follow suite for consistency.

Expected behavior

Only staged changes should be amended to the commit.

Actual behavior

All changes were commit ammended.

Version of rustc

No response

Automated bug report

No response

Version of git-branchless

git-branchless-opts 0.9.0

Version of git

git version 2.45.2

claytonrcarter commented 3 weeks ago

Hi @talios. Do you have any additional context that you can share, or can you share any steps for reproduction? I use amend all the time in the way that you describe; it should be behaving the same way as record: if anything is staged, only those changes will be added to the commit; if nothing is staged, then all unstaged changes will be added. If that's not happening for you, then ... I think more info will be needed to debug what's up.

talios commented 3 weeks ago

@claytonrcarter Hrm, man I'm an idiot - although maybe this is something that branchless could add somehow.

I already had an amend alias in my ~/.gitconfig - and no such alias in my .git/branchless/config - not sure if running git branchless init silently skips add aliases for things that already have aliases or not.

I had this a while ago with one of the other aliases. Closing this as a #postop-drug-confusion :)

arxanas commented 3 weeks ago

Yep, it will skip already-installed aliases as it doesn't want to clobber them. Possibly it warns, but I don't remember. Unfortunately, this has caused issues for at least one other amend enjoyer in the past 😫.