Skip to content

Commit

Permalink
Merge pull request #67 from guludo/amend-option
Browse files Browse the repository at this point in the history
Add --amend option
  • Loading branch information
keis authored Aug 23, 2023
2 parents 76c688c + 5c84fde commit 0d75087
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ script into your `$PATH` and `$fpath` respectively.
## Usage

```
git-fixup [-s|--squash] [-f|--fixup] [-c|--commit] [--no-verify]
git-fixup [-s|--squash] [-f|--fixup] [-a|--amend] [-c|--commit] [--no-verify]
[--rebase] [-b|--base <rev>] [<ref>]
```

Expand Down Expand Up @@ -78,6 +78,12 @@ Instruct `git-fixup` to create `fixup!` commit (This is the default).

Default action can be configured by setting [fixup.action](#fixupaction)

### -a, --amend

Instruct `git-fixup` to create an `amend!` commit.

Default action can be configured by setting [fixup.action](#fixupaction)

### -c, --commit

Instead of listing the suggested commits show a menu to pick a commit to
Expand Down
1 change: 1 addition & 0 deletions completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function _fixup_target {

_arguments -A \
'(-s --squash)'{-s,--squash}'[Create a squash commit rather than a fixup]' \
'(-a --amend)'{-a,--amend}'[Create an amend commit rather than a fixup]' \
'(-c --commit --no-commit)'{-c,--commit}'[Create a commit]' \
'(-c --commit --no-commit)'--no-commit"[Don't create a commit]" \
'(--rebase --no-rebase)'--rebase'[Do a rebase after commit]' \
Expand Down
12 changes: 11 additions & 1 deletion git-fixup
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ git fixup [options] [<ref>]
h,help Show this help text
s,squash Create a squash! commit
f,fixup Create a fixup! commit
a,amend Create an amend! commit
c,commit Show a menu from which to pick a commit
no-commit Don't show a menu to pick a commit
rebase Do a rebase right after commit
Expand Down Expand Up @@ -64,9 +65,15 @@ function print_sha () {

# Call git commit
function call_commit() {
local flag=$op
local target=$1

git commit ${git_commit_args[@]} --$op=$target
if test "$op" == "amend"; then
flag=fixup
target="amend:$target"
fi

git commit ${git_commit_args[@]} --$flag=$target
}

# Call git rebase
Expand Down Expand Up @@ -154,6 +161,9 @@ while test $# -gt 0; do
-f|--fixup)
op="fixup"
;;
-a|--amend)
op="amend"
;;
-c|--commit)
create_commit=true
;;
Expand Down

0 comments on commit 0d75087

Please # to comment.