Skip to content

Git.commit: CommitOptions.date only sets the author date, not the committer date #82

@joewalker

Description

@joewalker

Observed behavior

Git.commit in src/util/git.ts forwards options.date as --date=<iso> to git:

if (date != null) {
  args.push(`--date=${new Date(date).toISOString()}`);
}

Git's --date flag only sets the AUTHOR date. The committer date defaults to "now" unless GIT_COMMITTER_DATE is set. Because the API exposes a single date, callers will reasonably assume it sets the commit's timestamp, but only one of the two timestamps actually changes.

Expected behavior

A single date option should set both author and committer dates so the resulting commit is fully deterministic, or the option should be renamed/split to make the asymmetry explicit.

Minimal reproduction

const date = new Date('1970-01-01T00:00:00Z').getTime();
await git.commit('msg', {
  committer: { name: 'X', email: 'x@y' },
  date,
});
// git log -1 --format='AD=%ai CD=%ci'
// -> AD=1970-01-01 00:00:00 +0000  CD=2026-05-25 19:25:44 +0100

Verified with a standalone Node script that replicates the exact spawn arguments used by Git.commit.

Suggested fix

Set both timestamps via environment variables, which avoids relying on the asymmetric --date flag:

if (date != null) {
  const iso = new Date(date).toISOString();
  env['GIT_AUTHOR_DATE'] = iso;
  env['GIT_COMMITTER_DATE'] = iso;
}

Add a regression test that commits with a date and asserts both %ai and %ci match.

Metadata

Metadata

Assignees

No one assigned

    Labels

    S3Edge cases, confusing APIs, maintainability issues, or moderate performance problemsbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions