Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let the user merge branches. #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

tobiasBora
Copy link

A pretty simple pull request that let the user merge branches. This should correct this bug: #140

@iGEL
Copy link

iGEL commented Feb 12, 2018

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 😢

@tobiasBora
Copy link
Author

tobiasBora commented Feb 12, 2018 via email

@iGEL
Copy link

iGEL commented Feb 12, 2018

Thank you for the reply 👍

@ericamador
Copy link

Will either this or #107 get merged at some point?

@Quentin-M
Copy link

Quentin-M commented Oct 31, 2018

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

@plup
Copy link

plup commented Nov 3, 2018

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

if (access(state_mergetool_path.c_str(), F_OK) != 0) {
std::ofstream state_mergetool_file(state_mergetool_path.c_str());
// |--------------------------------------------------------------------------------| 80 chars
state_mergetool_file << "#!/usr/bin/env bash\n";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use /bin/sh instead of /usr/bin/env bash for better compatibility – not every system ships bash by default. /bin/sh exists on every *nix system, it’s defined by POSIX, and this script is compatible with POSIX shell.

@joaosa
Copy link

joaosa commented Jan 26, 2021

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

@Quentin-M
Copy link

There's also #180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants