jj icon indicating copy to clipboard operation
jj copied to clipboard

Need a way of setting name/email/timestamp for author/committer

Open martinvonz opened this issue 3 years ago • 4 comments

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

martinvonz avatar May 18 '22 15:05 martinvonz

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.

yuja avatar May 19 '22 07:05 yuja

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).

martinvonz avatar May 19 '22 15:05 martinvonz

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.

martinvonz avatar May 30 '22 00:05 martinvonz

"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.

yuja avatar May 30 '22 08:05 yuja

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'

dbarnett avatar Dec 13 '22 06:12 dbarnett

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".

martinvonz avatar Dec 14 '22 03:12 martinvonz

Both Git and Bazaar put this on the commit command as a flag.

joyously avatar Mar 17 '23 13:03 joyously

Where in jj you don't use a commit command but describe is the nearest equivalent, right?

dbarnett avatar Mar 18 '23 04:03 dbarnett

Yes, putting the functionality in describe is still my best bet.

martinvonz avatar Mar 18 '23 05:03 martinvonz

There's now jj describe --reset-author (added in #1395).

martinvonz avatar Mar 19 '23 16:03 martinvonz

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.

dbarnett avatar Mar 20 '23 03:03 dbarnett

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.

martinvonz avatar Mar 20 '23 04:03 martinvonz

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.

gasche avatar Dec 20 '23 22:12 gasche

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.

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.

martinvonz avatar Dec 20 '23 22:12 martinvonz