packaging: Add contrib installation
[platform/upstream/git.git] / commit.c
index 87686a7..fe1fa3d 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -37,7 +37,7 @@ struct commit *lookup_commit_reference_gently(struct repository *r,
 
        if (!obj)
                return NULL;
-       return object_as_type(r, obj, OBJ_COMMIT, quiet);
+       return object_as_type(obj, OBJ_COMMIT, quiet);
 }
 
 struct commit *lookup_commit_reference(struct repository *r, const struct object_id *oid)
@@ -62,7 +62,7 @@ struct commit *lookup_commit(struct repository *r, const struct object_id *oid)
        struct object *obj = lookup_object(r, oid);
        if (!obj)
                return create_object(r, oid, alloc_commit_node(r));
-       return object_as_type(r, obj, OBJ_COMMIT, 0);
+       return object_as_type(obj, OBJ_COMMIT, 0);
 }
 
 struct commit *lookup_commit_reference_by_name(const char *name)
@@ -339,7 +339,7 @@ struct tree *repo_get_commit_tree(struct repository *r,
        if (commit->maybe_tree || !commit->object.parsed)
                return commit->maybe_tree;
 
-       if (commit->graph_pos != COMMIT_NOT_FROM_GRAPH)
+       if (commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH)
                return get_commit_tree_in_graph(r, commit);
 
        return NULL;
@@ -423,6 +423,8 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b
        pptr = &item->parents;
 
        graft = lookup_commit_graft(r, &item->object.oid);
+       if (graft)
+               r->parsed_objects->substituted_parent = 1;
        while (bufptr + parent_entry_len < tail && !memcmp(bufptr, "parent ", 7)) {
                struct commit *new_parent;
 
@@ -729,11 +731,13 @@ int compare_commits_by_author_date(const void *a_, const void *b_,
 int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused)
 {
        const struct commit *a = a_, *b = b_;
+       const uint32_t generation_a = commit_graph_generation(a),
+                      generation_b = commit_graph_generation(b);
 
        /* newer commits first */
-       if (a->generation < b->generation)
+       if (generation_a < generation_b)
                return 1;
-       else if (a->generation > b->generation)
+       else if (generation_a > generation_b)
                return -1;
 
        /* use date as a heuristic when generations are equal */
@@ -917,7 +921,7 @@ struct commit *get_fork_point(const char *refname, struct commit *commit)
        struct commit *ret = NULL;
        char *full_refname;
 
-       switch (dwim_ref(refname, strlen(refname), &oid, &full_refname)) {
+       switch (dwim_ref(refname, strlen(refname), &oid, &full_refname, 0)) {
        case 0:
                die("No such ref: '%s'", refname);
        case 1:
@@ -1312,8 +1316,8 @@ int commit_tree(const char *msg, size_t msg_len, const struct object_id *tree,
        int result;
 
        append_merge_tag_headers(parents, &tail);
-       result = commit_tree_extended(msg, msg_len, tree, parents, ret,
-                                     author, sign_commit, extra);
+       result = commit_tree_extended(msg, msg_len, tree, parents, ret, author,
+                                     NULL, sign_commit, extra);
        free_commit_extra_headers(extra);
        return result;
 }
@@ -1436,7 +1440,8 @@ N_("Warning: commit message did not conform to UTF-8.\n"
 int commit_tree_extended(const char *msg, size_t msg_len,
                         const struct object_id *tree,
                         struct commit_list *parents, struct object_id *ret,
-                        const char *author, const char *sign_commit,
+                        const char *author, const char *committer,
+                        const char *sign_commit,
                         struct commit_extra_header *extra)
 {
        int result;
@@ -1469,7 +1474,9 @@ int commit_tree_extended(const char *msg, size_t msg_len,
        if (!author)
                author = git_author_info(IDENT_STRICT);
        strbuf_addf(&buffer, "author %s\n", author);
-       strbuf_addf(&buffer, "committer %s\n", git_committer_info(IDENT_STRICT));
+       if (!committer)
+               committer = git_committer_info(IDENT_STRICT);
+       strbuf_addf(&buffer, "committer %s\n", committer);
        if (!encoding_is_utf8)
                strbuf_addf(&buffer, "encoding %s\n", git_commit_encoding);
 
@@ -1579,7 +1586,7 @@ const char *find_commit_header(const char *msg, const char *key, size_t *out_len
 
 /*
  * Inspect the given string and determine the true "end" of the log message, in
- * order to find where to put a new Signed-off-by: line.  Ignored are
+ * order to find where to put a new Signed-off-by trailer.  Ignored are
  * trailing comment lines and blank lines.  To support "git commit -s
  * --amend" on an existing commit, we also ignore "Conflicts:".  To
  * support "git commit -v", we truncate at cut lines.
@@ -1626,22 +1633,22 @@ size_t ignore_non_trailer(const char *buf, size_t len)
 int run_commit_hook(int editor_is_used, const char *index_file,
                    const char *name, ...)
 {
-       struct argv_array hook_env = ARGV_ARRAY_INIT;
+       struct strvec hook_env = STRVEC_INIT;
        va_list args;
        int ret;
 
-       argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
+       strvec_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=:");
+               strvec_push(&hook_env, "GIT_EDITOR=:");
 
        va_start(args, name);
-       ret = run_hook_ve(hook_env.argv,name, args);
+       ret = run_hook_ve(hook_env.v, name, args);
        va_end(args);
-       argv_array_clear(&hook_env);
+       strvec_clear(&hook_env);
 
        return ret;
 }