Git Flow のマージコミットについて

## 背景
自分一人のプロジェクトで開発中，GitHub で PR を開くのを横着してローカルで `git flow feature finish ...` とした．その時，マージコミットが発生せず直接 `develop` にコミットが生える形でマージされた．

それだと後からのコミットログの見通しが悪いので，できればマージコミットを作ってほしい．そのため，原因の調査を行った．

```reproduce.sh
$ git init
Initialized empty Git repository in /path/to/project/.git/
$ echo 'test' > test.txt
$ git add test.txt
$ git commit -m 'initial commit'
[main (root-commit) ab0702e] initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt
$ git flow init

Which branch should be used for bringing forth production releases?
   - main
Branch name for production releases: [main]
Branch name for "next release" development: [develop]

How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []
$ git flow feature start hoge
Switched to a new branch 'feature/hoge'

Summary of actions:
- A new branch 'feature/hoge' was created, based on 'develop'
- You are now on branch 'feature/hoge'

Now, start committing on your feature. When done, use:

     git flow feature finish hoge

$ echo 'update' > test.txt
$ git commit -m 'update test.txt'
[feature/hoge 6a501b3] update test.txt
 1 file changed, 1 insertion(+), 1 deletion(-)

$ git flow feature finish hoge
Switched to branch 'develop'
Updating ab0702e..6a501b3
Fast-forward
 test.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Deleted branch feature/hoge (was 6a501b3).

Summary of actions:
- The feature branch 'feature/hoge' was merged into 'develop'
- Feature branch 'feature/hoge' has been removed
- You are now on branch 'develop'

$ git log
commit 6a501b3ca67efd86b9deca9f2861784a7d0f2c09 (HEAD -> develop)
Author: kino-ma <ma[AT]kino.ma>
Date:   Sun Dec 5 11:33:41 2021 +0900

    update test.txt

commit ab0702e2740306296e87e21f9b717407903a14f4 (main)
Author: kino-ma <ma[AT]kino.ma>
Date:   Sun Dec 5 11:32:58 2021 +0900

    initial commit
```

## 調査
GitFlow のリポジトリで， [issue](https://github.com/nvie/gitflow/issues/100) が建てられていた． [オーナーのコメント](https://github.com/nvie/gitflow/issues/100#issuecomment-769968) によると，

> Hi Scott,
> 
> By design, git-flow uses the --no-ff option when merging in order to record that the commits belong together historically. However, when the feature branch contains only a single commit, the extra merge commit does not add anything and only complicates the branch tree needlessly. So for single-commit branches, fast-forward merges are being made as if the commit was done on develop directly.
> 
> Cheers,
> Vincent

ということなので，コミットが一つしかない Feature ブランチを `finish` するときは，自動で fast-forward するようになっているらしい．理由としては，「コミットが一つしかないブランチのためにマージコミットを作成しても，不必要に複雑になるから」とのこと．

その考え方は確かにもっともなので， *解決* は望まずこれからはこの思想に従っていこうと思う．そもそも， Feature ブランチを 1 コミットで終わらせることはそれほどないが．

ちなみに，二つ以上のコミットで確かめたところ，ちゃんとマージコミットが発生した．

```no-ff.sh
$ git flow feature start fuga
Switched to a new branch 'feature/fuga'

Summary of actions:
- A new branch 'feature/fuga' was created, based on 'develop'
- You are now on branch 'feature/fuga'

Now, start committing on your feature. When done, use:

     git flow feature finish fuga

$ echo 'recent update' > test.txt
$ git add test.txt
$ git commit -m 'new changes'
[feature/fuga 02f429a] new changes
 1 file changed, 1 insertion(+), 1 deletion(-)
$ git
$ echo 'latest update' > test2.txt
$ git add test2.txt
$ git commit -m 'newest commit'
[feature/fuga 1b96b5d] newest commit
 1 file changed, 1 insertion(+)
 create mode 100644 test2.txt
$ git flow feature finish fuga
## エディタが起動してマージコミットメッセージの編集画面に入る ##
Switched to branch 'develop'
Merge made by the 'recursive' strategy.
 test.txt  | 2 +-
 test2.txt | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 test2.txt
Deleted branch feature/fuga (was 1b96b5d).

Summary of actions:
- The feature branch 'feature/fuga' was merged into 'develop'
- Feature branch 'feature/fuga' has been removed
- You are now on branch 'develop'

$ git log
commit 749095dca880aab548e0415c76b879b319cdcf34 (HEAD -> develop)
Merge: 6a501b3 1b96b5d
Author: kino-ma <ma[AT]kino.ma>
Date:   Sun Dec 5 11:47:33 2021 +0900

    Merge branch 'feature/fuga' into develop

commit 1b96b5db38eae5c26a6740e5856f689e50741f56
Author: kino-ma <ma[AT]kino.ma>
Date:   Sun Dec 5 11:47:24 2021 +0900

    newest commit

commit 02f429abaa787b9c4d969186e06a13b1707177e3
Author: kino-ma <ma[AT]kino.ma>
Date:   Sun Dec 5 11:46:56 2021 +0900

    new changes

commit 6a501b3ca67efd86b9deca9f2861784a7d0f2c09
Author: kino-ma <ma[AT]kino.ma>
Date:   Sun Dec 5 11:33:41 2021 +0900

    update test.txt

commit ab0702e2740306296e87e21f9b717407903a14f4 (main)
Author: kino-ma <ma[AT]kino.ma>
Date:   Sun Dec 5 11:32:58 2021 +0900

    initial commit
```

## 結論
GitFlow では，コミットが一つしかない場合は Fast Forward するようになっている．