OSDN Git Service

Git DLL get hash basic work
authorFrank Li <lznuaa@gmail.com>
Sun, 27 Dec 2009 13:43:38 +0000 (21:43 +0800)
committerFrank Li <lznuaa@gmail.com>
Sun, 27 Dec 2009 13:43:38 +0000 (21:43 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
ext/gitdll/gitdll.c
ext/gitdll/gitdll.h
ext/gitdll/gitdll.vcproj
ext/gitdlltest/gitdlltest.cpp
ext/gitdlltest/gitdlltest.vcproj

index af92ef0..47cdc52 100644 (file)
@@ -3,7 +3,7 @@
 \r
 #include "stdafx.h"\r
 #include "gitdll.h"\r
-\r
+#include "cache.h"\r
 #if 0\r
 \r
 // This is an example of an exported variable\r
@@ -45,4 +45,36 @@ void dll_entry()
 int git_get_sha1(const char *name, unsigned char *sha1)\r
 {\r
        return get_sha1(name,sha1);\r
+}\r
+\r
+static int convert_slash(char * path)\r
+{\r
+       while(*path)\r
+       {\r
+               if(*path == '\\' )\r
+                       *path = '/';\r
+               path++;\r
+       }\r
+}\r
+int git_init()\r
+{\r
+       char *home;\r
+       char path[MAX_PATH+1];\r
+       char *prefix;\r
+       size_t homesize,size,httpsize;\r
+\r
+       // set HOME if not set already\r
+       getenv_s(&homesize, NULL, 0, "HOME");\r
+       if (!homesize)\r
+       {\r
+               _dupenv_s(&home,&size,"USERPROFILE"); \r
+               _putenv_s("HOME",home);\r
+               free(home);\r
+       }\r
+       GetModuleFileName(NULL, path, MAX_PATH);\r
+       convert_slash(path);\r
+\r
+       git_extract_argv0_path(path);\r
+       prefix = setup_git_directory();\r
+       git_config(git_default_config, NULL);\r
 }
\ No newline at end of file
index 2b83be8..f887712 100644 (file)
@@ -30,4 +30,5 @@ GITDLL_API int ngitdll;
 GITDLL_API int fngitdll(void);\r
 \r
 GITDLL_API char * get_git_last_error();\r
-GITDLL_API int git_get_sha1(const char *name, unsigned char *sha1);
\ No newline at end of file
+GITDLL_API int git_get_sha1(const char *name, unsigned char *sha1);\r
+GITDLL_API int git_init();
\ No newline at end of file
index 9ada15b..0175fa3 100644 (file)
@@ -24,7 +24,7 @@
                        OutputDirectory="$(SolutionDir)\..\bin\$(ConfigurationName)\bin"\r
                        IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="2"\r
-                       CharacterSet="1"\r
+                       CharacterSet="0"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
@@ -44,6 +44,7 @@
                        <Tool\r
                                Name="VCCLCompilerTool"\r
                                Optimization="0"\r
+                               AdditionalIncludeDirectories="..\tgit;..\tgit\compat;..\tgit\compat\vcbuild;;..\tgit\compat\vcbuild\include;..\tgit\compat\fnmatch;..\tgit\compat\regex;..\zlib;"\r
                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GITDLL_EXPORTS"\r
                                MinimalRebuild="true"\r
                                BasicRuntimeChecks="3"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="$(SolutionDir)\..\bin\$(ConfigurationName)\bin"\r
-                       IntermediateDirectory="$(ConfigurationName)"\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="1"\r
-                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="2"\r
-                               EnableIntrinsicFunctions="true"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GITDLL_EXPORTS"\r
-                               RuntimeLibrary="2"\r
-                               EnableFunctionLevelLinking="true"\r
+                               Optimization="0"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GITDLL_EXPORTS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
                                DebugInformationFormat="3"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="wininet.lib ws2_32.lib "\r
-                               LinkIncremental="1"\r
+                               LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
+                               TargetMachine="17"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Debug|x64"\r
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)\..\bin\$(ConfigurationName)\bin"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GITDLL_EXPORTS"\r
-                               MinimalRebuild="true"\r
-                               BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="3"\r
+                               Optimization="2"\r
+                               EnableIntrinsicFunctions="true"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GITDLL_EXPORTS"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
                                DebugInformationFormat="3"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="wininet.lib ws2_32.lib "\r
-                               LinkIncremental="2"\r
+                               LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               TargetMachine="17"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                                        />\r
                                </FileConfiguration>\r
                                <FileConfiguration\r
-                                       Name="Release|Win32"\r
+                                       Name="Debug|x64"\r
                                        >\r
                                        <Tool\r
                                                Name="VCCLCompilerTool"\r
                                        />\r
                                </FileConfiguration>\r
                                <FileConfiguration\r
-                                       Name="Debug|x64"\r
+                                       Name="Release|Win32"\r
                                        >\r
                                        <Tool\r
                                                Name="VCCLCompilerTool"\r
index 6b0b39c..b50f130 100644 (file)
@@ -8,6 +8,7 @@ int _tmain(int argc, _TCHAR* argv[])
 {\r
        unsigned char hash[20];\r
        int ret;\r
+       ret=git_init();\r
        ret=git_get_sha1("master",hash);\r
        return ret;\r
 }\r
index 923d62d..f5953be 100644 (file)
@@ -24,7 +24,7 @@
                        OutputDirectory="$(SolutionDir)\..\bin\$(ConfigurationName)\bin"\r
                        IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="1"\r
-                       CharacterSet="1"\r
+                       CharacterSet="0"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="$(SolutionDir)\..\bin\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(ConfigurationName)"\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
                        ConfigurationType="1"\r
                        CharacterSet="1"\r
-                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="2"\r
-                               EnableIntrinsicFunctions="true"\r
+                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\gitdll"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
-                               RuntimeLibrary="2"\r
-                               EnableFunctionLevelLinking="true"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
                                UsePrecompiledHeader="2"\r
                                WarningLevel="3"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               LinkIncremental="1"\r
+                               LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="1"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
+                               TargetMachine="17"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Debug|x64"\r
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)\..\bin\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="1"\r
                        CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
+                               Optimization="2"\r
+                               EnableIntrinsicFunctions="true"\r
                                AdditionalIncludeDirectories="..\gitdll"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"\r
-                               MinimalRebuild="true"\r
-                               BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="3"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"\r
+                               RuntimeLibrary="2"\r
+                               EnableFunctionLevelLinking="true"\r
                                UsePrecompiledHeader="2"\r
                                WarningLevel="3"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               LinkIncremental="2"\r
+                               LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="1"\r
-                               TargetMachine="17"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                                        />\r
                                </FileConfiguration>\r
                                <FileConfiguration\r
-                                       Name="Release|Win32"\r
+                                       Name="Debug|x64"\r
                                        >\r
                                        <Tool\r
                                                Name="VCCLCompilerTool"\r
                                        />\r
                                </FileConfiguration>\r
                                <FileConfiguration\r
-                                       Name="Debug|x64"\r
+                                       Name="Release|Win32"\r
                                        >\r
                                        <Tool\r
                                                Name="VCCLCompilerTool"\r