From a561d5efab17e7d7a450af2aad1a9dd3ca232f2e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 27 Dec 2012 10:53:13 -0800 Subject: [PATCH] Only create diff options when necessary --- native/v8_extensions/git.mm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/native/v8_extensions/git.mm b/native/v8_extensions/git.mm index 3c572504d..e767b66fa 100644 --- a/native/v8_extensions/git.mm +++ b/native/v8_extensions/git.mm @@ -114,17 +114,6 @@ public: return CefV8Value::CreateNull(); } - char *copiedPath = (char *)malloc(sizeof(char) * (strlen(path) + 1)); - strcpy(copiedPath, path); - git_diff_options options; - memset(&options, 0, sizeof(options)); - git_strarray paths; - paths.count = 1; - paths.strings = &copiedPath; - options.pathspec = paths; - options.context_lines = 1; - options.flags = GIT_DIFF_DISABLE_PATHSPEC_MATCH; - git_reference *head; if (git_repository_head(&head, repo) != GIT_OK) { return CefV8Value::CreateNull(); @@ -145,6 +134,17 @@ public: return CefV8Value::CreateNull(); } + char *copiedPath = (char *)malloc(sizeof(char) * (strlen(path) + 1)); + strcpy(copiedPath, path); + git_diff_options options; + memset(&options, 0, sizeof(options)); + git_strarray paths; + paths.count = 1; + paths.strings = &copiedPath; + options.pathspec = paths; + options.context_lines = 1; + options.flags = GIT_DIFF_DISABLE_PATHSPEC_MATCH; + git_diff_list *diffs; int diffStatus = git_diff_workdir_to_tree(repo, &options, tree, &diffs); if (diffStatus != GIT_OK) {