Skip to content

Commit

Permalink
commit: restore --edit when combined with --fixup
Browse files Browse the repository at this point in the history
Recent changes to --fixup, adding amend suboption, caused the
--edit flag to be ignored as use_editor was always set to zero.

Restore edit_flag having higher priority than fixup_message when
deciding the value of use_editor by only changing the default
if edit_flag is not set.

Signed-off-by: Joel Klinghed <the_jk@spawned.biz>
  • Loading branch information
thejk committed Aug 11, 2021
1 parent ebf3c04 commit 0ee926d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion builtin/commit.c
Expand Up @@ -1333,7 +1333,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
} else {
fixup_commit = fixup_message;
fixup_prefix = "fixup";
use_editor = 0;
if (0 > edit_flag)
use_editor = 0;
}
}

Expand Down
15 changes: 15 additions & 0 deletions t/t7500-commit-template-squash-signoff.sh
Expand Up @@ -281,6 +281,21 @@ test_expect_success 'commit --fixup -m"something" -m"extra"' '
extra"
'
test_expect_success 'commit --fixup --edit' '
commit_for_rebase_autosquash_setup &&
cat >e-append <<-\EOF &&
#!/bin/sh
sed -e "2a\\
something\\
extra" <"$1" >"$1-"
mv "$1-" "$1"
EOF
chmod 755 e-append &&
EDITOR="./e-append" git commit --fixup HEAD~1 --edit &&
commit_msg_is "fixup! target message subject linesomething
extra"
'

get_commit_msg () {
rev="$1" &&
git log -1 --pretty=format:"%B" "$rev"
Expand Down

0 comments on commit 0ee926d

Please sign in to comment.