mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 14:02:48 +00:00
Merge pull request #1108 from libgit2/ahead-behind-count
Add API to calculate ahead/behind count
This commit is contained in:
commit
f684970a10
@ -23,6 +23,7 @@
|
||||
#include "git2/repository.h"
|
||||
#include "git2/revwalk.h"
|
||||
#include "git2/merge.h"
|
||||
#include "git2/graph.h"
|
||||
#include "git2/refs.h"
|
||||
#include "git2/reflog.h"
|
||||
#include "git2/revparse.h"
|
||||
|
36
include/git2/graph.h
Normal file
36
include/git2/graph.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2012 the libgit2 contributors
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
#ifndef INCLUDE_git_graph_h__
|
||||
#define INCLUDE_git_graph_h__
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "oid.h"
|
||||
|
||||
/**
|
||||
* @file git2/graph.h
|
||||
* @brief Git graph traversal routines
|
||||
* @defgroup git_revwalk Git graph traversal routines
|
||||
* @ingroup Git
|
||||
* @{
|
||||
*/
|
||||
GIT_BEGIN_DECL
|
||||
|
||||
/**
|
||||
* Count the number of unique commits between two commit objects
|
||||
*
|
||||
* @param ahead number of commits, starting at `one`, unique from commits in `two`
|
||||
* @param behind number of commits, starting at `two`, unique from commits in `one`
|
||||
* @param repo the repository where the commits exist
|
||||
* @param one one of the commits
|
||||
* @param two the other commit
|
||||
*/
|
||||
GIT_EXTERN(int) git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, const git_oid *one, const git_oid *two);
|
||||
|
||||
/** @} */
|
||||
GIT_END_DECL
|
||||
#endif
|
@ -127,7 +127,7 @@ static int commit_quick_parse(git_revwalk *walk, git_commit_list_node *commit, g
|
||||
if (git_oid_fromstr(&oid, (char *)buffer + strlen("parent ")) < 0)
|
||||
return -1;
|
||||
|
||||
commit->parents[i] = commit_lookup(walk, &oid);
|
||||
commit->parents[i] = git_revwalk__commit_lookup(walk, &oid);
|
||||
if (commit->parents[i] == NULL)
|
||||
return -1;
|
||||
|
||||
@ -181,9 +181,13 @@ int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit)
|
||||
|
||||
if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0)
|
||||
return error;
|
||||
assert(obj->raw.type == GIT_OBJ_COMMIT);
|
||||
|
||||
error = commit_quick_parse(walk, commit, &obj->raw);
|
||||
if (obj->raw.type != GIT_OBJ_COMMIT) {
|
||||
giterr_set(GITERR_INVALID, "Object is no commit object");
|
||||
error = -1;
|
||||
} else
|
||||
error = commit_quick_parse(walk, commit, &obj->raw);
|
||||
|
||||
git_odb_object_free(obj);
|
||||
return error;
|
||||
}
|
||||
|
93
src/graph.c
Normal file
93
src/graph.c
Normal file
@ -0,0 +1,93 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2012 the libgit2 contributors
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
|
||||
#include "revwalk.h"
|
||||
#include "merge.h"
|
||||
#include "git2/graph.h"
|
||||
|
||||
static int ahead_behind(git_commit_list_node *one, git_commit_list_node *two,
|
||||
size_t *ahead, size_t *behind)
|
||||
{
|
||||
git_commit_list_node *commit;
|
||||
git_pqueue pq;
|
||||
int i;
|
||||
*ahead = 0;
|
||||
*behind = 0;
|
||||
|
||||
if (git_pqueue_init(&pq, 2, git_commit_list_time_cmp) < 0)
|
||||
return -1;
|
||||
if (git_pqueue_insert(&pq, one) < 0)
|
||||
return -1;
|
||||
if (git_pqueue_insert(&pq, two) < 0)
|
||||
return -1;
|
||||
|
||||
while ((commit = git_pqueue_pop(&pq)) != NULL) {
|
||||
if (commit->flags & RESULT ||
|
||||
(commit->flags & (PARENT1 | PARENT2)) == (PARENT1 | PARENT2))
|
||||
continue;
|
||||
else if (commit->flags & PARENT1)
|
||||
(*behind)++;
|
||||
else if (commit->flags & PARENT2)
|
||||
(*ahead)++;
|
||||
|
||||
for (i = 0; i < commit->out_degree; i++) {
|
||||
git_commit_list_node *p = commit->parents[i];
|
||||
if (git_pqueue_insert(&pq, p) < 0)
|
||||
return -1;
|
||||
}
|
||||
commit->flags |= RESULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo,
|
||||
const git_oid *one, const git_oid *two)
|
||||
{
|
||||
git_revwalk *walk;
|
||||
git_vector list;
|
||||
struct git_commit_list *result = NULL;
|
||||
git_commit_list_node *commit1, *commit2;
|
||||
void *contents[1];
|
||||
|
||||
if (git_revwalk_new(&walk, repo) < 0)
|
||||
return -1;
|
||||
|
||||
commit2 = git_revwalk__commit_lookup(walk, two);
|
||||
if (commit2 == NULL)
|
||||
goto on_error;
|
||||
|
||||
/* This is just one value, so we can do it on the stack */
|
||||
memset(&list, 0x0, sizeof(git_vector));
|
||||
contents[0] = commit2;
|
||||
list.length = 1;
|
||||
list.contents = contents;
|
||||
|
||||
commit1 = git_revwalk__commit_lookup(walk, one);
|
||||
if (commit1 == NULL)
|
||||
goto on_error;
|
||||
|
||||
if (git_merge__bases_many(&result, walk, commit1, &list) < 0)
|
||||
goto on_error;
|
||||
if (ahead_behind(commit1, commit2, ahead, behind) < 0)
|
||||
goto on_error;
|
||||
|
||||
if (!result) {
|
||||
git_revwalk_free(walk);
|
||||
return GIT_ENOTFOUND;
|
||||
}
|
||||
|
||||
git_commit_list_free(&result);
|
||||
git_revwalk_free(walk);
|
||||
|
||||
return 0;
|
||||
|
||||
on_error:
|
||||
git_revwalk_free(walk);
|
||||
return -1;
|
||||
}
|
@ -71,14 +71,14 @@ int git_merge_base_many(git_oid *out, git_repository *repo, const git_oid input_
|
||||
goto cleanup;
|
||||
|
||||
for (i = 1; i < length; i++) {
|
||||
commit = commit_lookup(walk, &input_array[i]);
|
||||
commit = git_revwalk__commit_lookup(walk, &input_array[i]);
|
||||
if (commit == NULL)
|
||||
goto cleanup;
|
||||
|
||||
git_vector_insert(&list, commit);
|
||||
}
|
||||
|
||||
commit = commit_lookup(walk, &input_array[0]);
|
||||
commit = git_revwalk__commit_lookup(walk, &input_array[0]);
|
||||
if (commit == NULL)
|
||||
goto cleanup;
|
||||
|
||||
@ -112,7 +112,7 @@ int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const
|
||||
if (git_revwalk_new(&walk, repo) < 0)
|
||||
return -1;
|
||||
|
||||
commit = commit_lookup(walk, two);
|
||||
commit = git_revwalk__commit_lookup(walk, two);
|
||||
if (commit == NULL)
|
||||
goto on_error;
|
||||
|
||||
@ -122,7 +122,7 @@ int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const
|
||||
list.length = 1;
|
||||
list.contents = contents;
|
||||
|
||||
commit = commit_lookup(walk, one);
|
||||
commit = git_revwalk__commit_lookup(walk, one);
|
||||
if (commit == NULL)
|
||||
goto on_error;
|
||||
|
||||
@ -241,4 +241,3 @@ int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_l
|
||||
*out = result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,8 @@
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
git_commit_list_node *commit_lookup(git_revwalk *walk, const git_oid *oid)
|
||||
git_commit_list_node *git_revwalk__commit_lookup(
|
||||
git_revwalk *walk, const git_oid *oid)
|
||||
{
|
||||
git_commit_list_node *commit;
|
||||
khiter_t pos;
|
||||
@ -101,7 +102,7 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting)
|
||||
return -1;
|
||||
}
|
||||
|
||||
commit = commit_lookup(walk, oid);
|
||||
commit = git_revwalk__commit_lookup(walk, oid);
|
||||
if (commit == NULL)
|
||||
return -1; /* error already reported by failed lookup */
|
||||
|
||||
|
@ -39,6 +39,6 @@ struct git_revwalk {
|
||||
git_vector twos;
|
||||
};
|
||||
|
||||
git_commit_list_node *commit_lookup(git_revwalk *walk, const git_oid *oid);
|
||||
git_commit_list_node *git_revwalk__commit_lookup(git_revwalk *walk, const git_oid *oid);
|
||||
|
||||
#endif
|
||||
|
1
tests-clar/resources/twowaymerge.git/HEAD
Normal file
1
tests-clar/resources/twowaymerge.git/HEAD
Normal file
@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
5
tests-clar/resources/twowaymerge.git/config
Normal file
5
tests-clar/resources/twowaymerge.git/config
Normal file
@ -0,0 +1,5 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = true
|
||||
ignorecase = true
|
1
tests-clar/resources/twowaymerge.git/description
Normal file
1
tests-clar/resources/twowaymerge.git/description
Normal file
@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
6
tests-clar/resources/twowaymerge.git/info/exclude
Normal file
6
tests-clar/resources/twowaymerge.git/info/exclude
Normal file
@ -0,0 +1,6 @@
|
||||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
x<01>ŽM
|
||||
Â0F]çsËÌä§ ˆ¸Üz‚Iš¶Ši¤¦÷·^Áå{<>¾TKy4`6‡¶æš,y<>’9j§GJì8<C3AC>ÁÇÞb¢‘\Œfõ–5/
Ç^‰8v¹'ö<>‚ÙËœì`SÆ<><C386>%[›ë
|
||||
÷T[ƒ[×úŠ,púüÌsºL<C2BA>6o±Kµœ<C2B5>´5Ø;ŽèÕn÷›-ÿ= ²úÿDÃ
|
@ -0,0 +1,2 @@
|
||||
x<01>Í=Â0@aæœÂ ²Mê6BlH¬œ ¿m!RqïO¹ë7¼[‹
rÐ5g°N’Xƒ‹Å±)Eg]ÏDY2c R8xã7<C3A3>Û
|
||||
<EFBFBD>ØTáÞÁ½Rõo8~òœ®Ó¢óºØêèÔ[”™àˆ#¢Ùußjþ;`¼ùÔÙ7ó
|
@ -0,0 +1,3 @@
|
||||
x<01><>K
|
||||
Β0@]ηsK&<26>¤ <09>Έάz‚™4ιΫHMοo½‚ΫχΰρbY–©‚1t<31>[Jΰb<CEB0>lΙ<6C>µβ¥ν4vΙ΅±Lβ³
μ'—Υ›·΄V`B¦<42>ϋ .
|
||||
λΞIφm ο1υZ¨Η x―cΩΰKπhΰ^^ύΒ+\>?2·a<C2B7>γ.M,Λ°µtTB‹pΦ^kuΠc³¦ΏjV_«sFh
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
x<01>ν
Â0@ajOq<10>cßù"!D‡DËþKÂ1
|
||||
Îþ„h_ñéÅZÊ£AßÛC[s†aÌÈžp´I³±‰#‹„lB<6C>…œqÈêí×¼4ð<19>Z"<05>¡Ç(œyGF¢¢ød#y«<79>ò[›ë
|
||||
÷X[ƒ[×úJÅ/púüÊsºL<C2BA>6o¡‹µœA²èX„ሂ¨öºo¶ü7 ’úÔ¸Ec
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
x<01>ÎM‚0@a×=Å\@2ýcÜ™¸õeÚ†Rƒåþâܾŗǵ”¹<E2809D>RæÔ¶”@¢Šœ(i$™uOÉ1ö9Ro"“
¬9¸à¼x‡-
ü@¬µcc3;ê-KvHÊ+‡9ÙèÁFe¼{›êO®Á£ƒ{]b +\>¿òoãܦ}踖+Hm
z<>šàŒ„(Žzl¶ô7 ñ•œF-
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
x<01>ÎA @Qלb.`3S(‰1îLÜz‚<7A>B[µÅTzëܾÅÏ<C385>ež§
|
||||
D|¨kJCß3f‰´íȵœ‚uÙ ›L>YGMÌV½eMK<05>9¢ÑZˆƒ5ÙæHè¥õ¢#{¦ž¥E´J¶:–î±Ô
|
||||
·®åÕϲÀéó“Çp¦:n¡‰e>ƒ6-£sHGìÕ®ûfMÔS}ZE²
|
@ -0,0 +1 @@
|
||||
x<01>ŽË
Â09»Šm€hã_ÖBÜ<42>¸R<C2B8>ן„cœþ1-p<>§yšPKy4<79>RÚ–D›GŒF»ÀJvÉFE>‡1#q²Ž
j§ÅÛoimbvSŽŠYSbEr²Š¸»Q"eÓÑ{+üÞ–ºÁ=ÔÖà6Àµ¾bñ+œ>?òœ/ó£-;¡–3ŒÊhœ¬C‚#¢è´g¶ô÷<C3B4>XÄÌyF¤
|
@ -0,0 +1,3 @@
|
||||
x<01>ν
Â0@ajOqù7BtH´Lp¾ó%A8FÁÙŸ°íW<=ª¥Ì
¬õ‡¶æx"ÊŽØ$—%1†dÄcÏDNLˆ:Yv=©7®yiÐc
|
||||
l¤$Ž\b{‰DÂbOd‚Õ9x+
|
||||
·6ÕT[ƒ{·úₜ??yŽ×qnÓ–:ªåƯcÔÞÁQZ«]÷Í–ÿ¨¢¾7 H†
|
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
x<01>ÏKj1Ьç½óÊFj}Z‚¼3²Ê ¤VÏÇdFA#ß?’\ ËzÅu]—FÓSo" ‰JðÆ&‚^˜‚Ž,9$G’Eéd)7|¦&[6”(FU"&Žh<<1E>¯FÉc4AÆ¿>"ZÑQ;m9Û\;ïKP%1b9k‰93¤GŸkƒw®½Ãënõ£¬iƒçý[îÓuZúüÈ®ëhã¬"RÞÂY¥†C<E280A0>[]þ=0¼I›rKÏp—¶÷óO:Á²õ
|
||||
»pÝʯ
_¾(c‡
|
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
x<01>־½
ֲ0@ajOq<10>ש7'!D‡Dֻצ<> A$Fֱ<46><D6B1>°םW<=©ף<5׀<35><1E>Z
|
||||
8N(Cֱָzַ…$'2<06>!־>[):#D½zַµ,
z<><06> £M<C2A3>
d…=†ה‘t…µ³Nֵ=ך
|
||||
w©ֱƒk}ו9.pת<70>ה9^ֶ©=¶װI<D7B0>ֿ@ֶY<0C>‰בˆ=¢<>u<EFBFBD>lון€<D79F>װ°<>Dג
|
@ -0,0 +1 @@
|
||||
x²▐мJд0┘]В)НnV3$╧is"На∙O░Ш⌠Nе╤▓и╪©Я\·О|8╡╞Кр!dzХм╙тdXG/ч╚о╧p*┴╒CЁXЁ┬╨@Zб8|∙f[V÷0HD≥H⌠E]6╞■g╤I#g╚*Яо╜9UEФHфH!MHл┬уЯh┌╨R╕║эШuoП.{ОПz│≈ЩSв╡аЦМ┤|лоСр╞w╬х╬>│г1╨4▒C8;rn8Хq╚ш©├7kЁ╥╡иNui╥~ЧM╖Аэ^╜
|
@ -0,0 +1 @@
|
||||
x+)JMU044c040031QHdx6<78><36>ッ9{wkョ+昭q鍼O<E98DBC>ィd6>ノ|鳥X%>ス9j
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
x+)JMU044c040031QHdx6<78><36>ッ9{wkョ+昭q鍼O<E98DBC>ィd>ノ4|帝X%:79U
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
x<01><>MΒ F]s<>Ή€Ν0Γ_cά™Έυ@΅ΥH1•ή_Ό‚Ϋ—ο}y±–ςh@¤mK 8<>³ΩYΖθδ„Α<1A>4Ρ¨<CEA1>t^'¦`lPΩ‰·ί<C2B7>Ϊ Ο<g™y<E284A2>Y‘<59>Ω1*m΄<6D>»„™Fαχ¶Τ
ξ±¶·®υ5ΏΒισ#Οω2?Ϊ²‡!ΦrΙZ΅5Ζ<35>pD‡(:ν™-ύ} ²ψ#EΈ
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
2224e191514cb4bd8c566d80dac22dfcb1e9bb83
|
1
tests-clar/resources/twowaymerge.git/refs/heads/master
Normal file
1
tests-clar/resources/twowaymerge.git/refs/heads/master
Normal file
@ -0,0 +1 @@
|
||||
1c30b88f5f3ee66d78df6520a7de9e89b890818b
|
@ -0,0 +1 @@
|
||||
9b219343610c88a1187c996d0dc58330b55cee28
|
@ -3,10 +3,12 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
static git_repository *_repo;
|
||||
static git_repository *_repo2;
|
||||
|
||||
void test_revwalk_mergebase__initialize(void)
|
||||
{
|
||||
cl_git_pass(git_repository_open(&_repo, cl_fixture("testrepo.git")));
|
||||
cl_git_pass(git_repository_open(&_repo2, cl_fixture("twowaymerge.git")));
|
||||
}
|
||||
|
||||
void test_revwalk_mergebase__cleanup(void)
|
||||
@ -18,6 +20,7 @@ void test_revwalk_mergebase__cleanup(void)
|
||||
void test_revwalk_mergebase__single1(void)
|
||||
{
|
||||
git_oid result, one, two, expected;
|
||||
size_t ahead, behind;
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&one, "c47800c7266a2be04c571c04d5a6614691ea99bd "));
|
||||
cl_git_pass(git_oid_fromstr(&two, "9fd738e8f7967c078dceed8190330fc8648ee56a"));
|
||||
@ -25,11 +28,20 @@ void test_revwalk_mergebase__single1(void)
|
||||
|
||||
cl_git_pass(git_merge_base(&result, _repo, &one, &two));
|
||||
cl_assert(git_oid_cmp(&result, &expected) == 0);
|
||||
|
||||
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo, &one, &two));
|
||||
cl_assert_equal_i(ahead, 2);
|
||||
cl_assert_equal_i(behind, 1);
|
||||
|
||||
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo, &two, &one));
|
||||
cl_assert_equal_i(ahead, 1);
|
||||
cl_assert_equal_i(behind, 2);
|
||||
}
|
||||
|
||||
void test_revwalk_mergebase__single2(void)
|
||||
{
|
||||
git_oid result, one, two, expected;
|
||||
size_t ahead, behind;
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&one, "763d71aadf09a7951596c9746c024e7eece7c7af"));
|
||||
cl_git_pass(git_oid_fromstr(&two, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"));
|
||||
@ -37,11 +49,20 @@ void test_revwalk_mergebase__single2(void)
|
||||
|
||||
cl_git_pass(git_merge_base(&result, _repo, &one, &two));
|
||||
cl_assert(git_oid_cmp(&result, &expected) == 0);
|
||||
|
||||
cl_git_pass(git_graph_ahead_behind( &ahead, &behind, _repo, &one, &two));
|
||||
cl_assert_equal_i(ahead, 4);
|
||||
cl_assert_equal_i(behind, 1);
|
||||
|
||||
cl_git_pass(git_graph_ahead_behind( &ahead, &behind, _repo, &two, &one));
|
||||
cl_assert_equal_i(ahead, 1);
|
||||
cl_assert_equal_i(behind, 4);
|
||||
}
|
||||
|
||||
void test_revwalk_mergebase__merged_branch(void)
|
||||
{
|
||||
git_oid result, one, two, expected;
|
||||
size_t ahead, behind;
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&one, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"));
|
||||
cl_git_pass(git_oid_fromstr(&two, "9fd738e8f7967c078dceed8190330fc8648ee56a"));
|
||||
@ -52,11 +73,38 @@ void test_revwalk_mergebase__merged_branch(void)
|
||||
|
||||
cl_git_pass(git_merge_base(&result, _repo, &two, &one));
|
||||
cl_assert(git_oid_cmp(&result, &expected) == 0);
|
||||
|
||||
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo, &one, &two));
|
||||
cl_assert_equal_i(ahead, 0);
|
||||
cl_assert_equal_i(behind, 3);
|
||||
|
||||
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo, &two, &one));
|
||||
cl_assert_equal_i(ahead, 3);
|
||||
cl_assert_equal_i(behind, 0);
|
||||
}
|
||||
|
||||
void test_revwalk_mergebase__two_way_merge(void)
|
||||
{
|
||||
git_oid one, two;
|
||||
size_t ahead, behind;
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&one, "9b219343610c88a1187c996d0dc58330b55cee28"));
|
||||
cl_git_pass(git_oid_fromstr(&two, "a953a018c5b10b20c86e69fef55ebc8ad4c5a417"));
|
||||
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo2, &one, &two));
|
||||
|
||||
cl_assert_equal_i(ahead, 2);
|
||||
cl_assert_equal_i(behind, 8);
|
||||
|
||||
cl_git_pass(git_graph_ahead_behind(&ahead, &behind, _repo2, &two, &one));
|
||||
|
||||
cl_assert_equal_i(ahead, 8);
|
||||
cl_assert_equal_i(behind, 2);
|
||||
}
|
||||
|
||||
void test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND(void)
|
||||
{
|
||||
git_oid result, one, two;
|
||||
size_t ahead, behind;
|
||||
int error;
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&one, "763d71aadf09a7951596c9746c024e7eece7c7af"));
|
||||
@ -66,6 +114,11 @@ void test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND(void)
|
||||
cl_git_fail(error);
|
||||
|
||||
cl_assert_equal_i(GIT_ENOTFOUND, error);
|
||||
|
||||
cl_git_fail(git_graph_ahead_behind(&ahead, &behind, _repo, &one, &two));
|
||||
cl_git_fail(error);
|
||||
|
||||
cl_assert_equal_i(GIT_ENOTFOUND, error);
|
||||
}
|
||||
|
||||
void test_revwalk_mergebase__no_off_by_one_missing(void)
|
||||
@ -143,7 +196,7 @@ void test_revwalk_mergebase__many_merge_branch(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* $ git log --graph --all
|
||||
* testrepo.git $ git log --graph --all
|
||||
* * commit 763d71aadf09a7951596c9746c024e7eece7c7af
|
||||
* | Author: nulltoken <emeric.fermas@gmail.com>
|
||||
* | Date: Sun Oct 9 12:54:47 2011 +0200
|
||||
@ -222,3 +275,104 @@ void test_revwalk_mergebase__many_merge_branch(void)
|
||||
*
|
||||
* packed commit one
|
||||
*/
|
||||
|
||||
/*
|
||||
* twowaymerge.git $ git log --graph --all
|
||||
* * commit 9b219343610c88a1187c996d0dc58330b55cee28
|
||||
* |\ Merge: c37a783 2224e19
|
||||
* | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | Date: Tue Nov 27 20:31:04 2012 -0800
|
||||
* | |
|
||||
* | | Merge branch 'first-branch' into second-branch
|
||||
* | |
|
||||
* | * commit 2224e191514cb4bd8c566d80dac22dfcb1e9bb83
|
||||
* | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | Date: Tue Nov 27 20:28:51 2012 -0800
|
||||
* | |
|
||||
* | | j
|
||||
* | |
|
||||
* | * commit a41a49f8f5cd9b6cb14a076bf8394881ed0b4d19
|
||||
* | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | Date: Tue Nov 27 20:28:39 2012 -0800
|
||||
* | |
|
||||
* | | i
|
||||
* | |
|
||||
* | * commit 82bf9a1a10a4b25c1f14c9607b60970705e92545
|
||||
* | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | Date: Tue Nov 27 20:28:28 2012 -0800
|
||||
* | |
|
||||
* | | h
|
||||
* | |
|
||||
* * | commit c37a783c20d92ac92362a78a32860f7eebf938ef
|
||||
* | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | Date: Tue Nov 27 20:30:57 2012 -0800
|
||||
* | |
|
||||
* | | n
|
||||
* | |
|
||||
* * | commit 8b82fb1794cb1c8c7f172ec730a4c2db0ae3e650
|
||||
* | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | Date: Tue Nov 27 20:30:43 2012 -0800
|
||||
* | |
|
||||
* | | m
|
||||
* | |
|
||||
* * | commit 6ab5d28acbf3c3bdff276f7ccfdf29c1520e542f
|
||||
* | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | Date: Tue Nov 27 20:30:38 2012 -0800
|
||||
* | |
|
||||
* | | l
|
||||
* | |
|
||||
* * | commit 7b8c336c45fc6895c1c60827260fe5d798e5d247
|
||||
* | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | Date: Tue Nov 27 20:30:24 2012 -0800
|
||||
* | |
|
||||
* | | k
|
||||
* | |
|
||||
* | | * commit 1c30b88f5f3ee66d78df6520a7de9e89b890818b
|
||||
* | | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | | Date: Tue Nov 27 20:28:10 2012 -0800
|
||||
* | | |
|
||||
* | | | e
|
||||
* | | |
|
||||
* | | * commit 42b7311aa626e712891940c1ec5d5cba201946a4
|
||||
* | | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | | Date: Tue Nov 27 20:28:06 2012 -0800
|
||||
* | | |
|
||||
* | | | d
|
||||
* | | |
|
||||
* | | * commit a953a018c5b10b20c86e69fef55ebc8ad4c5a417
|
||||
* | | |\ Merge: bd1732c cdf97fd
|
||||
* | | |/ Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | |/| Date: Tue Nov 27 20:26:43 2012 -0800
|
||||
* | | |
|
||||
* | | | Merge branch 'first-branch'
|
||||
* | | |
|
||||
* | * | commit cdf97fd3bb48eb3827638bb33d208f5fd32d0aa6
|
||||
* | | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | | Date: Tue Nov 27 20:24:46 2012 -0800
|
||||
* | | |
|
||||
* | | | g
|
||||
* | | |
|
||||
* | * | commit ef0488f0b722f0be8bcb90a7730ac7efafd1d694
|
||||
* | | | Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | | Date: Tue Nov 27 20:24:39 2012 -0800
|
||||
* | | |
|
||||
* | | | f
|
||||
* | | |
|
||||
* | | * commit bd1732c43c68d712ad09e1d872b9be6d4b9efdc4
|
||||
* | |/ Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | | Date: Tue Nov 27 17:43:58 2012 -0800
|
||||
* | |
|
||||
* | | c
|
||||
* | |
|
||||
* | * commit 0c8a3f1f3d5f421cf83048c7c73ee3b55a5e0f29
|
||||
* |/ Author: Scott J. Goldman <scottjg@github.com>
|
||||
* | Date: Tue Nov 27 17:43:48 2012 -0800
|
||||
* |
|
||||
* | b
|
||||
* |
|
||||
* * commit 1f4c0311a24b63f6fc209a59a1e404942d4a5006
|
||||
* Author: Scott J. Goldman <scottjg@github.com>
|
||||
* Date: Tue Nov 27 17:43:41 2012 -0800
|
||||
*
|
||||
* a
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user