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 12, 2021
1 parent ebf3c04 commit 0c0cb64
Show file tree
Hide file tree
Showing 2 changed files with 9 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 (edit_flag < 0)
use_editor = 0;
}
}

Expand Down
7 changes: 7 additions & 0 deletions t/t7500-commit-template-squash-signoff.sh
Expand Up @@ -281,6 +281,13 @@ test_expect_success 'commit --fixup -m"something" -m"extra"' '
extra"
'
test_expect_success 'commit --fixup --edit' '
commit_for_rebase_autosquash_setup &&
EDITOR="printf \"something\nextra\" >>" 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 0c0cb64

Please sign in to comment.