Retrieve files from git diff

Viewed 39

I have "git diff" files for every adjacent commits of the certain repository. Here's a sample "git diff" file. (from the Bitcoin repository)

diff --git a/src/addrman.h b/src/addrman.h
index c4c2965..c012e3d 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -16,8 +16,6 @@
 #include <stdint.h>
 #include <vector>
 
-#include <openssl/rand.h>
-
 /** Extended statistics about a CAddress */
 class CAddrInfo : public CAddress
 {
@@ -384,7 +382,7 @@ class CAddrMan
     CAddrMan() : vRandom(0), vvTried(ADDRMAN_TRIED_BUCKET_COUNT, std::vector<int>(0)), vvNew(ADDRMAN_NEW_BUCKET_COUNT, std::set<int>())
     {
          nKey.resize(32);
-         RAND_bytes(&nKey[0], 32);
+         GetRandBytes(&nKey[0], 32);
 
          nIdCount = 0;
          nTried = 0;
diff --git a/src/key.cpp b/src/key.cpp
index 3c4fa77..a253f86 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -1,11 +1,11 @@
-// Copyright (c) 2009-2013 The Bitcoin developers
+// Copyright (c) 2009-2014 The Bitcoin developers
 // Distributed under the MIT/X11 software license, see the accompanying
 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
 
 #include "key.h"
 
 #include "crypto/sha2.h"
-#include <openssl/rand.h>
+#include "random.h"
 
 #ifdef USE_SECP256K1
 #include <secp256k1.h>
@@ -194,7 +194,7 @@ class CECKey {
         if (d2i_ECPrivateKey(&pkey, &pbegin, privkey.size())) {
             if(fSkipCheck)
                 return true;
-            
+
             // d2i_ECPrivateKey returns true if parsing succeeds.
             // This doesn't necessarily mean the key is valid.
             if (EC_KEY_check_key(pkey))
@@ -412,7 +412,7 @@ bool CKey::CheckSignatureElement(const unsigned char *vch, int len, bool half) {
 
 void CKey::MakeNewKey(bool fCompressedIn) {
     do {
-        RAND_bytes(vch, sizeof(vch));
+        GetRandBytes(vch, sizeof(vch));
     } while (!Check(vch));
     fValid = true;
     fCompressed = fCompressedIn;
@@ -745,5 +745,3 @@ bool ECC_InitSanityCheck() {
     return true;
 #endif
 }
-
-
(and so on)

Can I get all states(files) of commits from "git diff" files? From the empty repository, I want to retrieve all files of each commit by applying "git diff" continually to the previous state.

I'm working in python 3. Is there any library to do this job?

0 Answers
Related