summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/commit.c b/commit.c
index a98de16..52036bc 100644
--- a/commit.c
+++ b/commit.c
@@ -19,6 +19,7 @@
#include "advice.h"
#include "refs.h"
#include "commit-reach.h"
+#include "run-command.h"
static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
@@ -358,14 +359,15 @@ struct tree *repo_get_commit_tree(struct repository *r,
struct object_id *get_commit_tree_oid(const struct commit *commit)
{
- return &get_commit_tree(commit)->object.oid;
+ struct tree *tree = get_commit_tree(commit);
+ return tree ? &tree->object.oid : NULL;
}
void release_commit_memory(struct parsed_object_pool *pool, struct commit *c)
{
set_commit_tree(c, NULL);
- c->index = 0;
free_commit_buffer(pool, c);
+ c->index = 0;
free_commit_list(c->parents);
c->object.parsed = 0;
@@ -1580,3 +1582,26 @@ size_t ignore_non_trailer(const char *buf, size_t len)
}
return boc ? len - boc : len - cutoff;
}
+
+int run_commit_hook(int editor_is_used, const char *index_file,
+ const char *name, ...)
+{
+ struct argv_array hook_env = ARGV_ARRAY_INIT;
+ va_list args;
+ int ret;
+
+ argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
+
+ /*
+ * Let the hook know that no editor will be launched.
+ */
+ if (!editor_is_used)
+ argv_array_push(&hook_env, "GIT_EDITOR=:");
+
+ va_start(args, name);
+ ret = run_hook_ve(hook_env.argv,name, args);
+ va_end(args);
+ argv_array_clear(&hook_env);
+
+ return ret;
+}