Merge branch 'ds/reachable'
The code for computing history reachability has been shuffled, obtained a bunch of new tests to cover them, and then being improved. * ds/reachable: commit-reach: correct accidental #include of C file commit-reach: use can_all_from_reach commit-reach: make can_all_from_reach... linear commit-reach: replace ref_newer logic test-reach: test commit_contains test-reach: test can_all_from_reach_with_flags test-reach: test reduce_heads test-reach: test get_merge_bases_many test-reach: test is_descendant_of test-reach: test in_merge_bases test-reach: create new test tool for ref_newer commit-reach: move can_all_from_reach_with_flags upload-pack: generalize commit date cutoff upload-pack: refactor ok_to_give_up() upload-pack: make reachable() more generic commit-reach: move commit_contains from ref-filter commit-reach: move ref_newer from remote.c commit.h: remove method declarations commit-reach: move walk methods from commit.c
This commit is contained in:
50
remote.c
50
remote.c
@ -12,6 +12,7 @@
|
||||
#include "string-list.h"
|
||||
#include "mergesort.h"
|
||||
#include "argv-array.h"
|
||||
#include "commit-reach.h"
|
||||
|
||||
enum map_direction { FROM_SRC, FROM_DST };
|
||||
|
||||
@ -1791,55 +1792,6 @@ int resolve_remote_symref(struct ref *ref, struct ref *list)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void unmark_and_free(struct commit_list *list, unsigned int mark)
|
||||
{
|
||||
while (list) {
|
||||
struct commit *commit = pop_commit(&list);
|
||||
commit->object.flags &= ~mark;
|
||||
}
|
||||
}
|
||||
|
||||
int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
|
||||
{
|
||||
struct object *o;
|
||||
struct commit *old_commit, *new_commit;
|
||||
struct commit_list *list, *used;
|
||||
int found = 0;
|
||||
|
||||
/*
|
||||
* Both new_commit and old_commit must be commit-ish and new_commit is descendant of
|
||||
* old_commit. Otherwise we require --force.
|
||||
*/
|
||||
o = deref_tag(the_repository, parse_object(the_repository, old_oid),
|
||||
NULL, 0);
|
||||
if (!o || o->type != OBJ_COMMIT)
|
||||
return 0;
|
||||
old_commit = (struct commit *) o;
|
||||
|
||||
o = deref_tag(the_repository, parse_object(the_repository, new_oid),
|
||||
NULL, 0);
|
||||
if (!o || o->type != OBJ_COMMIT)
|
||||
return 0;
|
||||
new_commit = (struct commit *) o;
|
||||
|
||||
if (parse_commit(new_commit) < 0)
|
||||
return 0;
|
||||
|
||||
used = list = NULL;
|
||||
commit_list_insert(new_commit, &list);
|
||||
while (list) {
|
||||
new_commit = pop_most_recent_commit(&list, TMP_MARK);
|
||||
commit_list_insert(new_commit, &used);
|
||||
if (new_commit == old_commit) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
unmark_and_free(list, TMP_MARK);
|
||||
unmark_and_free(used, TMP_MARK);
|
||||
return found;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup the upstream branch for the given branch and if present, optionally
|
||||
* compute the commit ahead/behind values for the pair.
|
||||
|
Reference in New Issue
Block a user