Need a way of setting name/email/timestamp for author/committer
Description
We need a way to override metadata on commits. In Git and Mercurial, the natural place to do that is when amending. Mercurial also has the metaedit extension for editing commit information. Perhaps we could copy that name? We could also put it on describe, but that's probably not where users would look for this feature?
Specifications
- Version: 0.4.0
I don't know if metaedit is discoverable name, but maybe describe could be
aliased to that command. I tend to use describe to fix up commit message of
earlier revisions, which is basically what hg metaedit would do.
True, it could be that we just alias them. That's actually similar to how we've considered rollling out hg metaedit internally - by making our current hg reword (for hg commit --amend 're:^$') instead be an alias for hg metaedit). I'm also very open to other names than metaedit. I'm not sure what I would look for myself if I wanted to reset the author/committer information on a commit. I might just scan/grep the jj help output for "author" or "committer", so maybe the most important thing is to include those terms in the help output (separate set-author and set-committer commands seem excessive, and not future proof).
We should also consider how to copy a description or a change ID from another commit. Maybe all this functionality can be provided by the same command.
"copy" could be implemented as a template expression (or some shorthand syntax for that.)
For example, jj describe -m @deadbeef copies commit description from deadbeef revision.
Obviously @ isn't a good prefix since we have @ revision.
If hg had such feature, it would look like hg metaedit -m "{revsingle(<revset>).desc}", and -m @<revset> for short.
FWIW, I did expect jj describe to help me update author, or at least to point me to a related command that did from jj help describe.
As a workaround, what's the simplest workflow to do this with existing commands? Best I found was:
jj co somecommit-
jj restore --from somecommit
jj describe -m 'Description from somecommit'
I think that's the best we have.
Thinking more about the command, maybe describe is the best place to put it. If we had a separate metaedit command, then it would be weird for that to not be able for setting the description. And if it could do all that describe can (and more), then why would we have describe? So maybe describe is the best place, maybe adding metaedit as an alias? jj help describe currently says "Edit the change description". We could just change that to something like "Set the change description or other metadata".
Both Git and Bazaar put this on the commit command as a flag.
Where in jj you don't use a commit command but describe is the nearest equivalent, right?
Yes, putting the functionality in describe is still my best bet.
There's now jj describe --reset-author (added in #1395).
Can we call this Fixed?
Between --reset-author & --no-edit and env vars, seems like you've nicely covered "a way of setting name/email/timestamp". You can reset name/email using --reset-author (or even set them to arbitrary values using JJ_USER=foo JJ_EMAIL="[email protected]" jj describe --reset-author --no-edit), and timestamp can be bumped the same way.
I left it open because I had not added a --author-name="Some One" option, but I think you're right that we can having the user pass those values via environment variables (or config options) is good enough for now. Thanks for pointing that out.
I spent ten minutes looking for how to specify/change the author of a jj change -- I find it very surprising in particular that jj describe does not let us do this. I finally gave up, assumed that it was not possible, and decided to look for issues discussing this.
It looks like the workaround above can be used:
JJ_USER=foo JJ_EMAIL="[email protected]" jj describe --reset-author --no-edit
but this is not documented anywhere that I could find except here, which means that the feature is not at all discoverable. (Question: what kind of jj help ... command can I use to learn about those JJ_* environment variables?)
I think that a good first step would be to show exactly this example in the documentation of --reset-author. But I also believe that adding explicit describe options to set the author would be nice.
I think that a good first step would be to show exactly this example in the documentation of
--reset-author. But I also believe that adding explicitdescribeoptions to set the author would be nice.
That sounds good to me. Do you think you can find time to implement it?
(Question: what kind of
jj help ...command can I use to learn about those JJ_* environment variables?)
I don't think it's documented anywhere yet :( Maybe it should be documented in https://martinvonz.github.io/jj/v0.12.0/config/#user-settings. We have documentation of how $JJ_EDITOR overrides ui.editor there, so it seems consistent to document how $JJ_USER/$JJ_EMAIL work there.