Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ Or `GITFIXUPBASE`
The default argument for `--base`. You can set the value `closest` to make
`git-fixup` use the closest ancestor branch by default, for example.

### fixup.format

Or `GITFIXUPFORMAT`

The format string used to display fixup candidates. This is passed to `git log`
and as such supports the same format options as git itself with one minor
alteration: The string 'TYPE' is replaced by the source of the candidate, 'F'
for file, or 'L' for line.

Refer to the git manual for details.

### fixup.action

Or `GITFIXUPACTION`
Expand Down
19 changes: 16 additions & 3 deletions git-fixup
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,18 @@ fixup_candidates_all_commits () {
print_sha () {
local sha=$1
local type=$2
local format=''

git --no-pager log --format="%h %ai [$type] %s <%ae>" -n 1 "$sha"
case "$type" in
F)
format="$formatf"
;;
L)
format="$formatl"
;;
esac

git --no-pager log --format="$format" -n 1 "$sha"
}

# Call git commit
Expand Down Expand Up @@ -167,7 +177,7 @@ show_menu () {

sort_commits () {
# shellcheck disable=SC2086
sort $sort_flags $additional_sort_flags
sort -k2 $additional_sort_flags
}

git_commit_args=()
Expand All @@ -178,8 +188,11 @@ fixup_menu=${GITFIXUPMENU:-$(git config --default="" fixup.menu)}
create_commit=${GITFIXUPCOMMIT:-$(git config --default=false --type bool fixup.commit)}
base=${GITFIXUPBASE:-$(git config --default="" fixup.base)}
show_all=false
sort_flags="-k2 -k3 -k4" # default flags to sort by time (eg 2025-01-03 10:04:43 +0100, hence 3 fields)
additional_sort_flags=${GITFIXUPADDITIONALSORTFLAGS:-$(git config --default="" fixup.additionalSortFlags)}
format=${GITFIXUPFORMAT:-$(git config --default "%h %ai [TYPE] %s <%ae>" fixup.format)}
formatf=$(echo "$format" | sed 's/TYPE/F/g')
formatl=$(echo "$format" | sed 's/TYPE/L/g')

while test $# -gt 0; do
case "$1" in
-s|--squash)
Expand Down
Loading