git-js icon indicating copy to clipboard operation
git-js copied to clipboard

Splitter character in the log result

Open adamsol opened this issue 1 year ago • 1 comments

When I run the following git log command with a custom format:

simpleGit().log({
    format: {
        subject: '%s',
        body: '%b',
    },
});

I'm getting the splitter character at the end of the subject, like this:

{
    "subject": "Initial commit ò",
    "body": "",
}

It happens only when the body is empty. When I swap the order of attributes in the format dictionary, the character is displayed at the beginning instead. Everything seems to work fine if there's at least one attribute in the format dictionary both before and after body.

Git version: 2.37.2.windows.2

adamsol avatar Mar 24 '24 21:03 adamsol

Another use case -- I wanted to get the commit hash and parent hash:

simpleGit().log({
    format: {
        hash: '%H',
        parents: '%P',
    },
});

Seemed to work fine, but not for the initial commit, which also got the additional ò character at the end, as parents is empty in this case.

adamsol avatar Mar 24 '24 23:03 adamsol