aboutsummaryrefslogtreecommitdiffstats
path: root/community/git-crypt/0001-add-merge-driver.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/git-crypt/0001-add-merge-driver.patch')
-rw-r--r--community/git-crypt/0001-add-merge-driver.patch218
1 files changed, 62 insertions, 156 deletions
diff --git a/community/git-crypt/0001-add-merge-driver.patch b/community/git-crypt/0001-add-merge-driver.patch
index 771cc56e333..41df5247764 100644
--- a/community/git-crypt/0001-add-merge-driver.patch
+++ b/community/git-crypt/0001-add-merge-driver.patch
@@ -16,10 +16,40 @@ Patch-Source: https://github.com/AGWA/git-crypt/pull/180
2 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/commands.cpp b/commands.cpp
-index d25c4cc..93a840e 100644
+index 81c401d..28bcdee 100644
--- a/commands.cpp
+++ b/commands.cpp
-@@ -690,8 +690,8 @@ static int parse_plumbing_options (const char** key_name, const char** key_file,
+@@ -166,11 +166,16 @@ static void configure_git_filters (const char* key_name)
+ git_config(std::string("filter.git-crypt-") + key_name + ".required", "true");
+ git_config(std::string("diff.git-crypt-") + key_name + ".textconv",
+ escaped_git_crypt_path + " diff --key-name=" + key_name);
++ git_config(std::string("merge.git-crypt-") + key_name + ".name", "git-crypt merge driver");
++ git_config(std::string("merge.git-crypt-") + key_name + ".driver",
++ escaped_git_crypt_path + " merge --key-name=" + key_name + " %A %O %B %L");
+ } else {
+ git_config("filter.git-crypt.smudge", escaped_git_crypt_path + " smudge");
+ git_config("filter.git-crypt.clean", escaped_git_crypt_path + " clean");
+ git_config("filter.git-crypt.required", "true");
+ git_config("diff.git-crypt.textconv", escaped_git_crypt_path + " diff");
++ git_config("merge.git-crypt.name", "git-crypt merge driver");
++ git_config("merge.git-crypt.driver", escaped_git_crypt_path + " merge %A %O %B %L");
+ }
+ }
+
+@@ -187,6 +192,12 @@ static void deconfigure_git_filters (const char* key_name)
+ if (git_has_config("diff." + attribute_name(key_name) + ".textconv")) {
+ git_deconfig("diff." + attribute_name(key_name));
+ }
++
++ if (git_has_config("merge." + attribute_name(key_name) + ".name") ||
++ git_has_config("merge." + attribute_name(key_name) + ".driver")) {
++
++ git_deconfig("merge." + attribute_name(key_name));
++ }
+ }
+
+ static bool git_checkout_batch (std::vector<std::string>::const_iterator paths_begin, std::vector<std::string>::const_iterator paths_end)
+@@ -712,8 +723,8 @@ static int parse_plumbing_options (const char** key_name, const char** key_file,
return parse_options(options, argc, argv);
}
@@ -30,7 +60,7 @@ index d25c4cc..93a840e 100644
{
const char* key_name = 0;
const char* key_path = 0;
-@@ -724,10 +724,10 @@ int clean (int argc, const char** argv)
+@@ -746,10 +757,10 @@ int clean (int argc, const char** argv)
char buffer[1024];
@@ -44,7 +74,7 @@ index d25c4cc..93a840e 100644
hmac.add(reinterpret_cast<unsigned char*>(buffer), bytes_read);
file_size += bytes_read;
-@@ -775,8 +775,8 @@ int clean (int argc, const char** argv)
+@@ -797,8 +808,8 @@ int clean (int argc, const char** argv)
hmac.get(digest);
// Write a header that...
@@ -55,7 +85,7 @@ index d25c4cc..93a840e 100644
// Now encrypt the file and write to stdout
Aes_ctr_encryptor aes(key->aes_key, digest);
-@@ -787,7 +787,7 @@ int clean (int argc, const char** argv)
+@@ -809,7 +820,7 @@ int clean (int argc, const char** argv)
while (file_data_len > 0) {
const size_t buffer_len = std::min(sizeof(buffer), file_data_len);
aes.process(file_data, reinterpret_cast<unsigned char*>(buffer), buffer_len);
@@ -64,7 +94,7 @@ index d25c4cc..93a840e 100644
file_data += buffer_len;
file_data_len -= buffer_len;
}
-@@ -803,14 +803,14 @@ int clean (int argc, const char** argv)
+@@ -825,14 +836,14 @@ int clean (int argc, const char** argv)
aes.process(reinterpret_cast<unsigned char*>(buffer),
reinterpret_cast<unsigned char*>(buffer),
buffer_len);
@@ -81,7 +111,7 @@ index d25c4cc..93a840e 100644
{
const unsigned char* nonce = header + 10;
uint32_t key_version = 0; // TODO: get the version from the file header
-@@ -828,7 +828,7 @@ static int decrypt_file_to_stdout (const Key_file& key_file, const unsigned char
+@@ -850,7 +861,7 @@ static int decrypt_file_to_stdout (const Key_file& key_file, const unsigned char
in.read(reinterpret_cast<char*>(buffer), sizeof(buffer));
aes.process(buffer, buffer, in.gcount());
hmac.add(buffer, in.gcount());
@@ -90,7 +120,7 @@ index d25c4cc..93a840e 100644
}
unsigned char digest[Hmac_sha1_state::LEN];
-@@ -844,8 +844,8 @@ static int decrypt_file_to_stdout (const Key_file& key_file, const unsigned char
+@@ -866,8 +877,8 @@ static int decrypt_file_to_stdout (const Key_file& key_file, const unsigned char
return 0;
}
@@ -101,7 +131,7 @@ index d25c4cc..93a840e 100644
{
const char* key_name = 0;
const char* key_path = 0;
-@@ -864,8 +864,8 @@ int smudge (int argc, const char** argv)
+@@ -886,8 +897,8 @@ int smudge (int argc, const char** argv)
// Read the header to get the nonce and make sure it's actually encrypted
unsigned char header[10 + Aes_ctr_decryptor::NONCE_LEN];
@@ -112,7 +142,7 @@ index d25c4cc..93a840e 100644
// File not encrypted - just copy it out to stdout
std::clog << "git-crypt: Warning: file not encrypted" << std::endl;
std::clog << "git-crypt: Run 'git-crypt status' to make sure all files are properly encrypted." << std::endl;
-@@ -873,12 +873,12 @@ int smudge (int argc, const char** argv)
+@@ -895,12 +906,12 @@ int smudge (int argc, const char** argv)
std::clog << "git-crypt: this file may be unencrypted in the repository's history. If this" << std::endl;
std::clog << "git-crypt: file contains sensitive information, you can use 'git filter-branch'" << std::endl;
std::clog << "git-crypt: to remove its old versions from the history." << std::endl;
@@ -128,149 +158,14 @@ index d25c4cc..93a840e 100644
}
int diff (int argc, const char** argv)
-@@ -920,7 +920,7 @@ int diff (int argc, const char** argv)
+@@ -942,7 +953,107 @@ int diff (int argc, const char** argv)
}
// Go ahead and decrypt it
- return decrypt_file_to_stdout(key_file, header, in);
+ return decrypt_file_to_stream(key_file, header, in);
- }
-
- void help_init (std::ostream& out)
-diff --git a/commands.hpp b/commands.hpp
-index f441e93..bf4632c 100644
---- a/commands.hpp
-+++ b/commands.hpp
-@@ -33,6 +33,7 @@
-
- #include <string>
- #include <iosfwd>
-+#include <iostream>
-
- struct Error {
- std::string message;
-@@ -41,8 +42,8 @@ struct Error {
- };
-
- // Plumbing commands:
--int clean (int argc, const char** argv);
--int smudge (int argc, const char** argv);
-+int clean (int argc, const char** argv, std::istream& in = std::cin, std::ostream& out = std::cout);
-+int smudge (int argc, const char** argv, std::istream& in = std::cin, std::ostream& out = std::cout);
- int diff (int argc, const char** argv);
- // Public commands:
- int init (int argc, const char** argv);
-
-From b2efa705c4bd8c5d5590816226aace123bf19265 Mon Sep 17 00:00:00 2001
-From: Jakub Jirutka <jakub@jirutka.cz>
-Date: Sun, 28 Jul 2019 19:18:39 +0200
-Subject: [PATCH 2/2] Add git-crypt merge driver to support secret files
- merging
-
-This commit is based on #107.
-
-Co-Authored-By: Shlomo Shachar <shlomo.shachar@binatix.com>
-Patch-Source: https://github.com/AGWA/git-crypt/pull/180
----
- README | 8 ++--
- README.md | 8 ++--
- commands.cpp | 111 +++++++++++++++++++++++++++++++++++++++++++
- commands.hpp | 1 +
- doc/multiple_keys.md | 2 +-
- git-crypt.cpp | 4 ++
- man/git-crypt.xml | 8 ++--
- 7 files changed, 129 insertions(+), 13 deletions(-)
-
-diff --git a/README b/README
-index 232947f..2810a26 100644
---- a/README
-+++ b/README
-@@ -28,8 +28,8 @@ Configure a repository to use git-crypt:
-
- Specify files to encrypt by creating a .gitattributes file:
-
-- secretfile filter=git-crypt diff=git-crypt
-- *.key filter=git-crypt diff=git-crypt
-+ secretfile filter=git-crypt diff=git-crypt merge=git-crypt
-+ *.key filter=git-crypt diff=git-crypt merge=git-crypt
-
- Like a .gitignore file, it can match wildcards and should be checked into
- the repository. See below for more information about .gitattributes.
-@@ -151,8 +151,8 @@ Also note that the pattern `dir/*` does not match files under
- sub-directories of dir/. To encrypt an entire sub-tree dir/, place the
- following in dir/.gitattributes:
-
-- * filter=git-crypt diff=git-crypt
-- .gitattributes !filter !diff
-+ * filter=git-crypt diff=git-crypt merge=git-crypt
-+ .gitattributes !filter !diff !merge
-
- The second pattern is essential for ensuring that .gitattributes itself
- is not encrypted.
-diff --git a/README.md b/README.md
-index d24517a..d008aab 100644
---- a/README.md
-+++ b/README.md
-@@ -29,8 +29,8 @@ Configure a repository to use git-crypt:
-
- Specify files to encrypt by creating a .gitattributes file:
-
-- secretfile filter=git-crypt diff=git-crypt
-- *.key filter=git-crypt diff=git-crypt
-+ secretfile filter=git-crypt diff=git-crypt merge=git-crypt
-+ *.key filter=git-crypt diff=git-crypt merge=git-crypt
-
- Like a .gitignore file, it can match wildcards and should be checked into
- the repository. See below for more information about .gitattributes.
-@@ -153,8 +153,8 @@ Also note that the pattern `dir/*` does not match files under
- sub-directories of dir/. To encrypt an entire sub-tree dir/, place the
- following in dir/.gitattributes:
-
-- * filter=git-crypt diff=git-crypt
-- .gitattributes !filter !diff
-+ * filter=git-crypt diff=git-crypt merge=git-crypt
-+ .gitattributes !filter !diff !merge
-
- The second pattern is essential for ensuring that .gitattributes itself
- is not encrypted.
-diff --git a/commands.cpp b/commands.cpp
-index 93a840e..415b36a 100644
---- a/commands.cpp
-+++ b/commands.cpp
-@@ -160,11 +160,16 @@ static void configure_git_filters (const char* key_name)
- git_config(std::string("filter.git-crypt-") + key_name + ".required", "true");
- git_config(std::string("diff.git-crypt-") + key_name + ".textconv",
- escaped_git_crypt_path + " diff --key-name=" + key_name);
-+ git_config(std::string("merge.git-crypt-") + key_name + ".name", "git-crypt merge driver");
-+ git_config(std::string("merge.git-crypt-") + key_name + ".driver",
-+ escaped_git_crypt_path + " merge --key-name=" + key_name + " %A %O %B %L");
- } else {
- git_config("filter.git-crypt.smudge", escaped_git_crypt_path + " smudge");
- git_config("filter.git-crypt.clean", escaped_git_crypt_path + " clean");
- git_config("filter.git-crypt.required", "true");
- git_config("diff.git-crypt.textconv", escaped_git_crypt_path + " diff");
-+ git_config("merge.git-crypt.name", "git-crypt merge driver");
-+ git_config("merge.git-crypt.driver", escaped_git_crypt_path + " merge %A %O %B %L");
- }
- }
-
-@@ -181,6 +186,12 @@ static void deconfigure_git_filters (const char* key_name)
- if (git_has_config("diff." + attribute_name(key_name) + ".textconv")) {
- git_deconfig("diff." + attribute_name(key_name));
- }
-+
-+ if (git_has_config("merge." + attribute_name(key_name) + ".name") ||
-+ git_has_config("merge." + attribute_name(key_name) + ".driver")) {
++}
+
-+ git_deconfig("merge." + attribute_name(key_name));
-+ }
- }
-
- static bool git_checkout (const std::vector<std::string>& paths)
-@@ -923,6 +934,106 @@ int diff (int argc, const char** argv)
- return decrypt_file_to_stream(key_file, header, in);
- }
-
+int merge (int argc, const char** argv)
+{
+ const char* key_name = 0; // unused but needed
@@ -369,18 +264,29 @@ index 93a840e..415b36a 100644
+ }
+
+ return ret;
-+}
-+
+ }
+
void help_init (std::ostream& out)
- {
- // |--------------------------------------------------------------------------------| 80 chars
diff --git a/commands.hpp b/commands.hpp
-index bf4632c..51f4aea 100644
+index f441e93..51f4aea 100644
--- a/commands.hpp
+++ b/commands.hpp
-@@ -45,6 +45,7 @@ struct Error {
- int clean (int argc, const char** argv, std::istream& in = std::cin, std::ostream& out = std::cout);
- int smudge (int argc, const char** argv, std::istream& in = std::cin, std::ostream& out = std::cout);
+@@ -33,6 +33,7 @@
+
+ #include <string>
+ #include <iosfwd>
++#include <iostream>
+
+ struct Error {
+ std::string message;
+@@ -41,9 +42,10 @@ struct Error {
+ };
+
+ // Plumbing commands:
+-int clean (int argc, const char** argv);
+-int smudge (int argc, const char** argv);
++int clean (int argc, const char** argv, std::istream& in = std::cin, std::ostream& out = std::cout);
++int smudge (int argc, const char** argv, std::istream& in = std::cin, std::ostream& out = std::cout);
int diff (int argc, const char** argv);
+int merge (int argc, const char** argv);
// Public commands:
@@ -422,7 +328,7 @@ index 9505834..d8c2072 100644
std::clog << "git-crypt: Error: " << e.option_name << ": " << e.message << std::endl;
help_for_command(command, std::clog);
diff --git a/man/git-crypt.xml b/man/git-crypt.xml
-index 96f53d7..21e1359 100644
+index f8ec765..4b2e631 100644
--- a/man/git-crypt.xml
+++ b/man/git-crypt.xml
@@ -310,11 +310,11 @@