Closed MageSlayer closed 5 days ago
Hi,
I'm not sure I understand exactly what you are trying to do in your example.
Assuming in your example you want to keep the file changes in both branches and apply the transcrypt encryption added on the t1
branch, a normal merge of the encrypting commit into your main branch works fine:
git switch master
git merge t1
<prompted for commit message>
Please use merge for situations like this where you are applying encryption to pre-existing files.
After experimenting with your example script for a while it seems like cherry-pick
fails in situations where a standard merge
operation works. I didn't expect this and I'm not sure why it is happening, but it seems that the cherry picking of changes is processed differently enough by git that transcrypt isn't being invoked correctly to make sense of the incoming changes vs the existing files. I don't think this is a general problem, but rather it's a problem that occurs when cherry-picking between transcrypt-aware and transcrypt-unaware branches – or more to the point, branches with and without the .gitattributes file.
If I try to use cherry-pick to apply the same logical change as with the merge
above I get the error you have been seeing:
git switch master
git cherry-pick t1
. . .
error: Your local changes to the following files would be overwritten by merge:
file1.txt
file2.txt
Please commit your changes or stash them before you merge.
Aborting
fatal: cherry-pick failed
The only way I've found to make a cherry-pick work in this situation is to configure the target branch with transcrypt support with .gitattributes etc prior to cherry-picking, and even then a lot of extra hand-holding is required to successfully cherry-pick the changes:
git switch master
# Configure transcrypt on main branch
cp ../.gitattributes .
git add ./.gitattributes
git rm --cached -- ./file1.txt ./file2.txt
git add ./file1.txt ./file2.txt
git commit -m "also transcrypted"
# Still fails with "error: Your local changes to the following files would be overwritten by merge:"
git cherry-pick t1
# But re-adding the files then committing finally succeeds
git add ./file1.txt ./file2.txt
git commit -m "worked, but hardly worth it"
So overally please use merges to apply newly-transcrypted files across branches, and once all the branches are configured for transcrypt and have encrypted versions of the files you should be able to return to your rebasing workflow.
I'm not sure I understand exactly what you are trying to do in your example.
Well. Originally my point was to try to encrypt some existing files in "master" branch and apply already prepared feature branch commit via rebasing on top of "master".
I use cherry-picking most of the time as it's conceptually easier for me & preserves linear history.
As I see "merge" works fine for some initial starting with transcrypt. And it's enough for me (thank you), but issues with cherry-picking / rebasing is worth documenting imho.
Hi
Perhaps I am doing something wrong, but I'd like to get some help on rebasing + transcrypt. Attached testcase tries to crypt existing files and then applies another branch changes to already encrypted files.
All I currently get is some strange errors like:
Surely enough commenting transcrypt initialization & usage (between "transcrypt start" / "transcrypt end" comments) makes cherry-pick apply successfully.
P.S. Test done using transcrypt 2.3.0 and git 2.45.2.
Any help? testcase.tar.gz