git-crypt icon indicating copy to clipboard operation
git-crypt copied to clipboard

Let the user merge branches.

Open tobiasBora opened this issue 7 years ago • 8 comments

A pretty simple pull request that let the user merge branches. This should correct this bug: https://github.com/AGWA/git-crypt/issues/140

tobiasBora avatar Jan 28 '18 03:01 tobiasBora

Does this also help with git add -p? I'm using that all the time and git considers the encrypted files to be binary, silently ignoring them 😢

iGEL avatar Feb 12 '18 15:02 iGEL

I'm sorry, put my patch seems to work with git merge, with the mergetools, ans with cherry-picking, but patching seems to be another problem. It looks like that there is no way to create a custom "patch" command thar overwrite the default behaviour, but it may be possible to write a custom script that do the sane thing, maybe by temporary jumping to a temp uncrypted git project, run the git add here, copy the file in the current folder, stash it, and replace it with the new version, but I'm not sure that there no better way to proceed… Sorry.

tobiasBora avatar Feb 12 '18 15:02 tobiasBora

Thank you for the reply 👍

iGEL avatar Feb 12 '18 16:02 iGEL

Will either this or https://github.com/AGWA/git-crypt/pull/107 get merged at some point?

ericamador avatar May 15 '18 14:05 ericamador

git-crypt is basically unusable without this. Is there any reason @AGWA this never has been merged?

Quentin-M avatar Oct 31 '18 22:10 Quentin-M

I tested this PR with the following process:

Initiate a repo with git-crypt:

$ mkdir /tmp/test1
$ cd !$
$ git init 
Initialized empty Git repository in /tmp/test1/.git/

$ git-crypt init
Generating key...

$ git-crypt add-gpg-user [email protected]
[master (root-commit) dc75cba] Add 1 git-crypt collaborator
 3 files changed, 19 insertions(+)
 create mode 100644 .git-crypt/.gitattributes
 create mode 100644 .git-crypt/keys/default/0/8A236E404A25F35A96B6ED57A953BD11758ED9D4.gpg
 create mode 100644 .git-crypt/merge-tool.sh

$ vi .gitattributes
* filter=git-crypt diff=git-crypt merge=git-crypt
.gitattributes !filter !diff !merge

$ echo 'some text' > text
$ git add .
$ git commit -m "added text"
$ git remote add origin [email protected]:plup/test.git
$ git push -u origin master

Create a second local repo:

$ git clone [email protected]:plup/test.git /tmp/test2
$ cd !$
$ git-crypt unlock

Make modification in both local repos:

$ cd /tmp/test1
$ echo 'another text' > text
$ git commit -am "wrote another text"
$ git push

$ cd /tmp/test2
$ echo 'will this work ?' > test
$ git commit -am "wrote another text again"

Try to merge:

$ git pull
From github.com:plup/test
   767190d..e98211c  master     -> origin/master
# Git crypt driver called #
Auto-merging text
CONFLICT (content): Merge conflict in text
Automatic merge failed; fix conflicts and then commit the result.

$ cat text 
<<<<<<< current branch
will this work ?
=======
another text
>>>>>>> other branch

So yeah, it works !

But this requires to start from a fresh repository as the script merge-tool.sh is created when gpg keys are added to the repository.

Thanks @tobiasBora

plup avatar Nov 03 '18 15:11 plup

I know it's been a while, but is there any chance this could be merged provided the issue above gets fixed? :)

joaosa avatar Jan 26 '21 10:01 joaosa

There's also https://github.com/AGWA/git-crypt/pull/180

Quentin-M avatar Feb 22 '21 19:02 Quentin-M