]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/pull.c
commit.h: remove method declarations
[thirdparty/git.git] / builtin / pull.c
index 25f7db5b3a2bcd6f4ad477b752a3f7c77c64f943..15ad01096817c9108e56647c4d52051968979a99 100644 (file)
 #include "remote.h"
 #include "dir.h"
 #include "refs.h"
+#include "refspec.h"
 #include "revision.h"
 #include "submodule.h"
 #include "submodule-config.h"
 #include "tempfile.h"
 #include "lockfile.h"
 #include "wt-status.h"
+#include "commit-reach.h"
 
 enum rebase_type {
        REBASE_INVALID = -1,
@@ -355,7 +357,7 @@ static int git_pull_config(const char *var, const char *value, void *cb)
  */
 static void get_merge_heads(struct oid_array *merge_heads)
 {
-       const char *filename = git_path_fetch_head();
+       const char *filename = git_path_fetch_head(the_repository);
        FILE *fp;
        struct strbuf sb = STRBUF_INIT;
        struct object_id oid;
@@ -672,19 +674,19 @@ static const char *get_upstream_branch(const char *remote)
 }
 
 /**
- * Derives the remote tracking branch from the remote and refspec.
+ * Derives the remote-tracking branch from the remote and refspec.
  *
  * FIXME: The current implementation assumes the default mapping of
  * refs/heads/<branch_name> to refs/remotes/<remote_name>/<branch_name>.
  */
 static const char *get_tracking_branch(const char *remote, const char *refspec)
 {
-       struct refspec *spec;
+       struct refspec_item spec;
        const char *spec_src;
        const char *merge_branch;
 
-       spec = parse_fetch_refspec(1, &refspec);
-       spec_src = spec->src;
+       refspec_item_init_or_die(&spec, refspec, REFSPEC_FETCH);
+       spec_src = spec.src;
        if (!*spec_src || !strcmp(spec_src, "HEAD"))
                spec_src = "HEAD";
        else if (skip_prefix(spec_src, "heads/", &spec_src))
@@ -704,13 +706,13 @@ static const char *get_tracking_branch(const char *remote, const char *refspec)
        } else
                merge_branch = NULL;
 
-       free_refspec(1, spec);
+       refspec_item_clear(&spec);
        return merge_branch;
 }
 
 /**
  * Given the repo and refspecs, sets fork_point to the point at which the
- * current branch forked from its remote tracking branch. Returns 0 on success,
+ * current branch forked from its remote-tracking branch. Returns 0 on success,
  * -1 on failure.
  */
 static int get_rebase_fork_point(struct object_id *fork_point, const char *repo,
@@ -764,10 +766,13 @@ static int get_octopus_merge_base(struct object_id *merge_base,
 {
        struct commit_list *revs = NULL, *result;
 
-       commit_list_insert(lookup_commit_reference(curr_head), &revs);
-       commit_list_insert(lookup_commit_reference(merge_head), &revs);
+       commit_list_insert(lookup_commit_reference(the_repository, curr_head),
+                          &revs);
+       commit_list_insert(lookup_commit_reference(the_repository, merge_head),
+                          &revs);
        if (!is_null_oid(fork_point))
-               commit_list_insert(lookup_commit_reference(fork_point), &revs);
+               commit_list_insert(lookup_commit_reference(the_repository, fork_point),
+                                  &revs);
 
        result = get_octopus_merge_bases(revs);
        free_commit_list(revs);
@@ -863,7 +868,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
        if (read_cache_unmerged())
                die_resolve_conflict("pull");
 
-       if (file_exists(git_path_merge_head()))
+       if (file_exists(git_path_merge_head(the_repository)))
                die_conclude_merge();
 
        if (get_oid("HEAD", &orig_head))
@@ -943,9 +948,11 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
                        struct commit_list *list = NULL;
                        struct commit *merge_head, *head;
 
-                       head = lookup_commit_reference(&orig_head);
+                       head = lookup_commit_reference(the_repository,
+                                                      &orig_head);
                        commit_list_insert(head, &list);
-                       merge_head = lookup_commit_reference(&merge_heads.oid[0]);
+                       merge_head = lookup_commit_reference(the_repository,
+                                                            &merge_heads.oid[0]);
                        if (is_descendant_of(merge_head, list)) {
                                /* we can fast-forward this without invoking rebase */
                                opt_ff = "--ff-only";