amend commit in Fossil

1.5k views Asked by At

In Git, to change the most recent commit on the current branch one uses the --amend option to git-commit.

What would be the closest operation in Fossil? Is there a way to add a GPG signature to an unsigned commit (git commit --amend -S)?

3

There are 3 answers

1
PenguinOutOfWater On BEST ANSWER

fossil amend can also just update the commit message:

    fossil amend COMMIT_ID -m 'my new commit message'

or

    fossil amend COMMIT_ID -e # launch $EDITOR to revise message

(These add a control artifact with the new/revised message which Fossil will display instead of the original.)

It has other functions as well: https://fossil-scm.org/fossil/help?cmd=amend

One possible way to add a sign-off to a commit might be:

    fossil amend COMMIT_D --tag sign-off=my_name

You could add a PGP/GPG signature to unsigned commit by turning on the manifest setting, checking out that commit, generating the PGP/GPG signature, then

    fossil amend COMMIT_ID --tag signature=SIGNATURE

Of course, this is harder than if amend directly supported adding a signature.

3
Benoit On

In fossil, there is no way to amend a commit. As documented in “Deleting content from Fossil”,

Fossil is designed to keep all historical content forever.

However you can if needed rollback a commit and redo it with proper GPG signature.

0
pechkin On

There is a way to amend a commit in Fossil, just like in git. In fact the mechanism is identical, but the process (and what data remains) is different.

Both tools will create a new commit (git doesn't amend the original any more than fossil does), the difference is only in what happens to the original commit.

In git, the old commit is left dangling until eventually deleted permanently (unless tagged).

In fossil, it is put on a hidden branch and kept permanently (but you can still view it if needed).

The process with git amend is: you make changes first, then update the repo database. In fossil, the other way around - which can also be done in git, shown below.

fossil (step 1 from: https://fossil-scm.org/fossil/doc/trunk/www/shunning.wiki):

$ # 1.
$ fossil amend abcd1234 --branch oops --hide
$ fossil up trunk

$ # 2.
$ fossil revert -r abcd1234

$ # 3.
$ $EDITOR the.file
$ fossil commit -m 'my new msg with amended code'

git:

$ # 1.
$ git reset --hard HEAD^

$ # 2.
$ git checkout abcd1234 .

$ # 3.
$ $EDITOR the.file
$ git commit -am 'my new msg with amended code'

In step 2, git still knows about the old commit as it hasn't been gc'd yet - you can see it in the reflog.

git amend just takes a shortcut, but the operations on the data are the same.