Skip to content

FR: Config option to preserve timestamp on history rewrite #9862

Description

@jakobhellermann

Problem

Sometimes I want to rewrite my commit history, without resetting every commit's committer timestamp to the current date.
Possible use cases include:

  • purging a file accidentally committed in an early commit
  • rewriting all commit messages into a common format before releasing a repo that was being developed in private before

You could argue that that's what the author timestamp is for, and that the commit timestamp should rightfully be changed in these instances, but the reality is that most code forges show the commit timestamp by default, and I don't think JJ should stand in the way of people wanting to control what the value of commit timestamps are, even if it doesn't entirely match reality.

EDIT: For some reason I thought I remembered that github and other forges show commit timestamp by default, not author timestamp. Maybe this is not be the case? I need to check. But the feature requests is still valid for author timestamps.

Possible Solutions

The obvious ideas for how to support this would be a command line flag or a config option, applying globally to every commit-rewriting operation.

Arguments in favor of config option:

  • I'm assuming this is a niche use case and doesn't need to clutter up the valuable help text and tab autocomplete
  • config options are more flexible, if you wanted to you could configure something like JJ_KEEP_COMMIT_TIMESTAMP=true jj sq -t foo to work
  • with a config option I can set the option, do some jj edit -r rev and make some changes and unset the option when I'm done rewriting.

Arguments in favor of CLI flag:

  • A config usually is configured persistently. I think this will be used more by one-off (or a couple) commands. This can be achieved by setting --config on the CLI so that's fine, but it feels a tiny bit like abusing configs.

I'd argue in favor of a config option.

Alternatives considered

Use something like git filter-repo in a colocated repository, and fix up the repo afterwards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions