Skip to content

Incorrect log if repo contains commits with empty message #481

Closed
@kpd200081

Description

@kpd200081

Subject of the issue

If repository contains commit made by git commit --allow-empty --allow-empty-message -m "" log return incorrect commits history. Returned history starts from this commit with empty message.

Your environment

$ git --version
git version 2.20.1
$ sudo gem install git     
Successfully installed git-1.7.0
$ ruby --version 
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]

Steps to reproduce

Create testing git repository:

mkdir test
cd test
git init
git commit -m "test" --allow-empty
git commit -m "test2" --allow-empty
git commit -m "" --allow-empty --allow-empty-message
git commit -m "test3" --allow-empty

Get real commit history:

$ git log | tee test
commit fc940fc8858011566d6a16076d01bcf189955b37
Author: ...
Date:   Mon Aug 10 17:34:10 2020 +0300

    test3

commit 58dc8ed01e328ea4cea39b28a01aa4500be5e385
Author: ...
Date:   Mon Aug 10 17:34:02 2020 +0300

commit 458f6e6b9305df15a9c23c3dffaf7448d917c72f
Author: ...
Date:   Mon Aug 10 17:33:43 2020 +0300

    test2

commit 9dd305fe98ef19385906e39cdb31ee7696f53e03
Author: ...
Date:   Mon Aug 10 17:33:37 2020 +0300

    test

Create test ruby script (named test.rb):

require "git"

g = Git.open("~/test")

g.log.to_a.each do |com|
   puts com.sha 
end

Call it:

$ ruby test.rb                                                 
fc940fc8858011566d6a16076d01bcf189955b37
58dc8ed01e328ea4cea39b28a01aa4500be5e385

As we can see this is not all commit history.

Expected behaviour

Retrieving complete commit history

Actual behaviour

The commit history is truncated from a commit with an empty message

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions