Unnamed: 0
int64
0
0
repo_id
stringlengths
5
186
file_path
stringlengths
15
223
content
stringlengths
1
32.8M
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/mergedrepo/conflicts-two.txt
<<<<<<< HEAD This is without question another conflict! ======= This is another conflict!!! >>>>>>> branch
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/mergedrepo/two.txt
This is file two! This is file two. This is file two. This is file two. This is file two. This is file two. This is file two. This is file two. This is file two. This is file two. This is file two. This is file two!
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/expected
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/expected/nodriver/diff.php
diff --git a/files/file.php b/files/file.php index 63250ad..967d646 100644 --- a/files/file.php +++ b/files/file.php @@ -12,2 +12,3 @@ class UniqueGenerator protected $maxRetries; + protected $moreStuff; protected $uniques = array(); @@ -17,3 +18,3 @@ class UniqueGenerator $this->generator = $generator; - $this->maxRetries = $maxRetries; + $this->maxRetries = $maxRetries + 1; } @@ -33,10 +34,10 @@ class UniqueGenerator { + $i = 0; if (!isset($this->uniques[$name])) { $this->uniques[$name] = array(); } - $i = 0; do { $res = call_user_func_array(array($this->generator, $name), $arguments); $i++; - if ($i > $this->maxRetries) { + if ($i >= $this->maxRetries) { throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries));
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/expected
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/expected/nodriver/diff.html
diff --git a/files/file.html b/files/file.html index 872d196..2320e2f 100644 --- a/files/file.html +++ b/files/file.html @@ -5,4 +5,4 @@ <li>item 1.1</li> - <li>item 1.2</li> - <li>item 1.3</li> + <li>item 1.2 changed</li> + <li>item 1.3 changed</li> <li>item 1.4</li> @@ -13,2 +13,3 @@ <li>item 1.9</li> + <li>item 1.10 added</li> </ol> @@ -23,3 +24,4 @@ <li>item 2.6</li> - <li>item 2.7</li> + <li>item 2.7 changed</li> + <li>item 2.7.1 added</li> <li>item 2.8</li> @@ -35,4 +37,2 @@ <li>item 3.6</li> - <li>item 3.7</li> - <li>item 3.8</li> </ol>
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/expected
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/expected/driver/diff.php
diff --git a/files/file.php b/files/file.php index 63250ad..967d646 100644 --- a/files/file.php +++ b/files/file.php @@ -12,2 +12,3 @@ class UniqueGenerator protected $maxRetries; + protected $moreStuff; protected $uniques = array(); @@ -17,3 +18,3 @@ public function __construct(Generator $generator, $maxRetries) $this->generator = $generator; - $this->maxRetries = $maxRetries; + $this->maxRetries = $maxRetries + 1; } @@ -33,10 +34,10 @@ public function __call($name, $arguments) { + $i = 0; if (!isset($this->uniques[$name])) { $this->uniques[$name] = array(); } - $i = 0; do { $res = call_user_func_array(array($this->generator, $name), $arguments); $i++; - if ($i > $this->maxRetries) { + if ($i >= $this->maxRetries) { throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries));
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/expected
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/expected/driver/diff.html
diff --git a/files/file.html b/files/file.html index 872d196..2320e2f 100644 --- a/files/file.html +++ b/files/file.html @@ -5,4 +5,4 @@ <h1 id="first section"> <li>item 1.1</li> - <li>item 1.2</li> - <li>item 1.3</li> + <li>item 1.2 changed</li> + <li>item 1.3 changed</li> <li>item 1.4</li> @@ -13,2 +13,3 @@ <h1 id="first section"> <li>item 1.9</li> + <li>item 1.10 added</li> </ol> @@ -23,3 +24,4 @@ <h1 id="second section"> <li>item 2.6</li> - <li>item 2.7</li> + <li>item 2.7 changed</li> + <li>item 2.7.1 added</li> <li>item 2.8</li> @@ -35,4 +37,2 @@ <h1 id="third section"> <li>item 3.6</li> - <li>item 3.7</li> - <li>item 3.8</li> </ol>
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/files/file.php
<?php namespace Faker; /** * Proxy for other generators, to return only unique values. Works with * Faker\Generator\Base->unique() */ class UniqueGenerator { protected $generator; protected $maxRetries; protected $moreStuff; protected $uniques = array(); public function __construct(Generator $generator, $maxRetries) { $this->generator = $generator; $this->maxRetries = $maxRetries + 1; } /** * Catch and proxy all generator calls but return only unique values */ public function __get($attribute) { return $this->__call($attribute, array()); } /** * Catch and proxy all generator calls with arguments but return only unique values */ public function __call($name, $arguments) { $i = 0; if (!isset($this->uniques[$name])) { $this->uniques[$name] = array(); } do { $res = call_user_func_array(array($this->generator, $name), $arguments); $i++; if ($i >= $this->maxRetries) { throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries)); } } while (in_array($res, $this->uniques[$name])); $this->uniques[$name][]= $res; return $res; } }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/files/file.html
<html> <body> <h1 id="first section"> <ol> <li>item 1.1</li> <li>item 1.2 changed</li> <li>item 1.3 changed</li> <li>item 1.4</li> <li>item 1.5</li> <li>item 1.6</li> <li>item 1.7</li> <li>item 1.8</li> <li>item 1.9</li> <li>item 1.10 added</li> </ol> </h1> <h1 id="second section"> <ol> <li>item 2.1</li> <li>item 2.2</li> <li>item 2.3</li> <li>item 2.4</li> <li>item 2.5</li> <li>item 2.6</li> <li>item 2.7 changed</li> <li>item 2.7.1 added</li> <li>item 2.8</li> </ol> </h1> <h1 id="third section"> <ol> <li>item 3.1</li> <li>item 3.2</li> <li>item 3.3</li> <li>item 3.4</li> <li>item 3.5</li> <li>item 3.6</li> </ol> </h1> </body> </html>
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/after/file.php
<?php namespace Faker; /** * Proxy for other generators, to return only unique values. Works with * Faker\Generator\Base->unique() */ class UniqueGenerator { protected $generator; protected $maxRetries; protected $moreStuff; protected $uniques = array(); public function __construct(Generator $generator, $maxRetries) { $this->generator = $generator; $this->maxRetries = $maxRetries + 1; } /** * Catch and proxy all generator calls but return only unique values */ public function __get($attribute) { return $this->__call($attribute, array()); } /** * Catch and proxy all generator calls with arguments but return only unique values */ public function __call($name, $arguments) { $i = 0; if (!isset($this->uniques[$name])) { $this->uniques[$name] = array(); } do { $res = call_user_func_array(array($this->generator, $name), $arguments); $i++; if ($i >= $this->maxRetries) { throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries)); } } while (in_array($res, $this->uniques[$name])); $this->uniques[$name][]= $res; return $res; } }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/after/file.html
<html> <body> <h1 id="first section"> <ol> <li>item 1.1</li> <li>item 1.2 changed</li> <li>item 1.3 changed</li> <li>item 1.4</li> <li>item 1.5</li> <li>item 1.6</li> <li>item 1.7</li> <li>item 1.8</li> <li>item 1.9</li> <li>item 1.10 added</li> </ol> </h1> <h1 id="second section"> <ol> <li>item 2.1</li> <li>item 2.2</li> <li>item 2.3</li> <li>item 2.4</li> <li>item 2.5</li> <li>item 2.6</li> <li>item 2.7 changed</li> <li>item 2.7.1 added</li> <li>item 2.8</li> </ol> </h1> <h1 id="third section"> <ol> <li>item 3.1</li> <li>item 3.2</li> <li>item 3.3</li> <li>item 3.4</li> <li>item 3.5</li> <li>item 3.6</li> </ol> </h1> </body> </html>
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/before/file.php
<?php namespace Faker; /** * Proxy for other generators, to return only unique values. Works with * Faker\Generator\Base->unique() */ class UniqueGenerator { protected $generator; protected $maxRetries; protected $uniques = array(); public function __construct(Generator $generator, $maxRetries) { $this->generator = $generator; $this->maxRetries = $maxRetries; } /** * Catch and proxy all generator calls but return only unique values */ public function __get($attribute) { return $this->__call($attribute, array()); } /** * Catch and proxy all generator calls with arguments but return only unique values */ public function __call($name, $arguments) { if (!isset($this->uniques[$name])) { $this->uniques[$name] = array(); } $i = 0; do { $res = call_user_func_array(array($this->generator, $name), $arguments); $i++; if ($i > $this->maxRetries) { throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a unique value', $this->maxRetries)); } } while (in_array($res, $this->uniques[$name])); $this->uniques[$name][]= $res; return $res; } }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/userdiff/before/file.html
<html> <body> <h1 id="first section"> <ol> <li>item 1.1</li> <li>item 1.2</li> <li>item 1.3</li> <li>item 1.4</li> <li>item 1.5</li> <li>item 1.6</li> <li>item 1.7</li> <li>item 1.8</li> <li>item 1.9</li> </ol> </h1> <h1 id="second section"> <ol> <li>item 2.1</li> <li>item 2.2</li> <li>item 2.3</li> <li>item 2.4</li> <li>item 2.5</li> <li>item 2.6</li> <li>item 2.7</li> <li>item 2.8</li> </ol> </h1> <h1 id="third section"> <ol> <li>item 3.1</li> <li>item 3.2</li> <li>item 3.3</li> <li>item 3.4</li> <li>item 3.5</li> <li>item 3.6</li> <li>item 3.7</li> <li>item 3.8</li> </ol> </h1> </body> </html>
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/binaryunicode/file.txt
Master branch.
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-resolve/unchanged.txt
this file is unchanged in both
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-resolve/removed-in-branch.txt
this is removed in branch
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-resolve/added-in-master.txt
this file is added in master
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-resolve/automergeable.txt
this file is changed in master this file is automergeable this file is automergeable this file is automergeable this file is automergeable this file is automergeable this file is automergeable this file is automergeable this file is automergeable
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-resolve/changed-in-master.txt
changed in master
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-resolve/changed-in-branch.txt
initial revision
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-resolve/conflicting.txt
this file is changed in master and branch
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/push_src/a.txt
a edit
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/push_src/foldb.txt
edit
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/push_src
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/push_src/submodule/new.txt
my new file
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/push_src
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/push_src/submodule/branch_file.txt
hi bye!
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/push_src
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/push_src/fold/b.txt
b
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/mailmap/file.txt
Added by Brad <[email protected]> Added by Brad L. <[email protected]> Added by nick1 <[email protected]> Added by nick2 <[email protected]> Added by nick3 <[email protected]> Added by Some Garbage <[email protected]> Added by unknown <[email protected]> Added by Joseph <[email protected]> Added by Clause <[email protected]> Added by Charles <[email protected]>
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/submodules-worktree-child/new.txt
my new file
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/submodules-worktree-child/branch_file.txt
hi bye!
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-recursive/veal.txt
VEAL SOUP. PUT INTO A POT THREE QUARTS OF WATER, 3 onions cut small, ONE spoonful of black pepper pounded, and two of salt, with two or three slices of lean ham; let it boil steadily two hours; skim it occasionally, then put into it a shin of veal, let it boil two hours longer; take out the slices of ham, and skim off the grease if any should rise, take a gill of good cream, mix with it two table-spoonsful of flour very nicely, and the yelks of two eggs beaten well, strain this mixture, and add some chopped parsley; pour some soup on by degrees, stir it well, and pour it into the pot, continuing to stir until it has boiled two or three minutes to take off the raw taste of the eggs. If the cream be not perfectly sweet, and the eggs quite new, the thickening will curdle in the soup. For a change you may put a dozen ripe tomatos in, first taking off their skins, by letting them stand a few minutes in hot water, when they may be easily peeled. When made in this way you must thicken it with the flour only. Any part of the veal may be used, but the shin or knuckle is the nicest. This is a mighty fine recipe!
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-recursive/oyster.txt
OYSTER SOUP! Wash and drain two quarts of oysters, put them on with three quarts of water, three onions chopped up, two or three slices of lean ham, pepper and salt; boil it till reduced one-half, strain it through a sieve, return the liquid into the pot, put in one quart of fresh oysters, boil it till they are sufficiently done, and thicken the soup with four spoonsful of flour, two gills of rich cream, and the yelks of six new laid eggs beaten well; boil it a few minutes after the thickening is put in. Take care that it does not curdle, and that the flour is not in lumps; serve it up with the last oysters that were put in. If the flavour of thyme be agreeable, you may put in a little, but take care that it does not boil in it long enough to discolour the soup.
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-recursive/bouilli.txt
SOUP WITH BOUILLI. Take the nicest part of the thick brisket of beef, about eight pounds, put it into a pot with every thing directed for the other soup; make it exactly in the same way, only put it on an hour sooner, that you may have time to prepare the bouilli; after it has boiled five hours, take out the beef, cover up the soup and set it near the fire that it may keep hot. Take the skin off the beef, have the yelk of an egg well beaten, dip a feather in it and wash the top of your beef, sprinkle over it the crumb of stale bread finely grated, put it in a Dutch oven previously heated, put the top on with coals enough to brown, but not burn the beef; let it stand nearly an hour, and prepare your gravy thus:--Take a sufficient quantity of soup and the vegetables boiled in it; add to it a table-spoonful of red wine, and two of mushroom catsup, thicken with a little bit of butter and a little brown flour; make it very hot, pour it in your dish, and put the beef on it. Garnish it with green pickle, cut in thin slices, serve up the soup in a tureen with bits of toasted bread.
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-recursive/gravy.txt
GRAVY SOUP. Get eight pounds of coarse lean beef--wash it clean and lay it in your pot, put in the same ingredients as for the shin soup, with the same quantity of water, and follow the process directed for that. Strain the soup through a sieve, and serve it up clear, with nothing more than toasted bread in it; two table-spoonsful of mushroom catsup will add a fine flavour to the soup.
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-recursive/beef.txt
BEEF SOUP. Take the hind shin of beef, cut off all the flesh off the leg-bone, which must be taken away entirely, or the soup will be greasy. Wash the meat clean and lay it in a pot, sprinkle over it one small table-spoonful of pounded black pepper, and two of salt; three onions the size of a hen's egg, cut small, six small carrots scraped and cut up, two small turnips pared and cut into dice; pour on three quarts of water, cover the pot close, and keep it gently and steadily boiling five hours, which will leave about three pints of clear soup; do not let the pot boil over, but take off the scum carefully, as it rises. When it has boiled four hours, put in a small bundle of thyme and parsley, and a pint of celery cut small, or a tea-spoonful of celery seed pounded. These latter ingredients would lose their delicate flavour if boiled too much. Just before you take it up, brown it in the following manner: put a small table-spoonful of nice brown sugar into an iron skillet, set it on the fire and stir it till it melts and looks very dark, pour into it a ladle full of the soup, a little at a time; stirring it all the while. Strain this browning and mix it well with the soup; take out the bundle of thyme and parsley, put the nicest pieces of meat in your tureen, and pour on the soup and vegetables; put in some toasted bread cut in dice, and serve it up.
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/merge-recursive/asparagus.txt
ASPARAGUS SOUP. Take four large bunches of asparagus, scrape it nicely, cut off one inch of the tops, and lay them in water, chop the stalks and put them on the fire with a piece of bacon, a large onion cut up, and pepper and salt; add two quarts of water, boil them till the stalks are quite soft, then pulp them through a sieve, and strain the water to it, which must be put back in the pot; put into it a chicken cut up, with the tops of asparagus which had been laid by, boil it until these last articles are sufficiently done, thicken with flour, butter and milk, and serve it up.
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592/a.txt
nothing here
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592/l.txt
nothing here
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592/t/a.txt
nothing here
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592/t/b.txt
nothing here
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592/c/a.txt
nothing here
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/attr_index/README.md
This is contains tests for when the index and work dir differ
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/attr_index/README.txt
This contains files for testing when the index and the workdir differ
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/attr_index/sub
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/attr_index/sub/sub/README.md
More testing
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/attr_index/sub
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/attr_index/sub/sub/README.txt
More testing
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_1397/crlf_file.txt
first line second line both with crlf
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_1397/some_other_crlf_file.txt
first line second line with some change both with crlf
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/diff_format_email/file2.txt
file2 file2 file2 file2! file2
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/diff_format_email/file3.txt
file3 file3! file3 file3 file3 file3 file3
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/diff_format_email
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/diff_format_email/dir/renamed.txt
file2 file2 file2 file2! file2
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/renames/sixserving.txt
I KEEP six honest serving-men (They taught me all I knew); Their names are What and Why and When And How and Where and Who. I send them over land and sea, I send them east and west; But after they have worked for me, I give them all a rest. I let them rest from nine till five, For I am busy then, As well as breakfast, lunch, and tea, For they are hungry men. But different folk have different views; I know a person small— She keeps ten million serving-men, Who get no rest at all! She sends'em abroad on her own affairs, From the second she opens her eyes— One million Hows, two million Wheres, And seven million Whys! -- Rudyard Kipling
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/renames/ikeepsix.txt
I Keep Six Honest Serving-Men ============================= She sends'em abroad on her own affairs, From the second she opens her eyes— One million Hows, two million Wheres, And seven million Whys! I let them rest from nine till five, For I am busy then, As well as breakfast, lunch, and tea, For they are hungry men. But different folk have different views; I know a person small— She keeps ten million serving-men, Who get no rest at all! -- Rudyard Kipling I KEEP six honest serving-men (They taught me all I knew); Their names are What and Why and When And How and Where and Who. I send them over land and sea, I send them east and west; But after they have worked for me, I give them all a rest.
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/renames/songof7cities.txt
The Song of Seven Cities ------------------------ I WAS Lord of Cities very sumptuously builded. Seven roaring Cities paid me tribute from afar. Ivory their outposts were--the guardrooms of them gilded, And garrisoned with Amazons invincible in war. All the world went softly when it walked before my Cities-- Neither King nor Army vexed my peoples at their toil, Never horse nor chariot irked or overbore my Cities, Never Mob nor Ruler questioned whence they drew their spoil. Banded, mailed and arrogant from sunrise unto sunset; Singing while they sacked it, they possessed the land at large. Yet when men would rob them, they resisted, they made onset And pierced the smoke of battle with a thousand-sabred charge. So they warred and trafficked only yesterday, my Cities. To-day there is no mark or mound of where my Cities stood. For the River rose at midnight and it washed away my Cities. They are evened with Atlantis and the towns before the Flood. Rain on rain-gorged channels raised the water-levels round them, Freshet backed on freshet swelled and swept their world from sight, Till the emboldened floods linked arms and, flashing forward, drowned them-- Drowned my Seven Cities and their peoples in one night! Low among the alders lie their derelict foundations, The beams wherein they trusted and the plinths whereon they built-- My rulers and their treasure and their unborn populations, Dead, destroyed, aborted, and defiled with mud and silt! The Daughters of the Palace whom they cherished in my Cities, My silver-tongued Princesses, and the promise of their May-- Their bridegrooms of the June-tide--all have perished in my Cities, With the harsh envenomed virgins that can neither love nor play. I was Lord of Cities--I will build anew my Cities, Seven, set on rocks, above the wrath of any flood. Nor will I rest from search till I have filled anew my Cities With peoples undefeated of the dark, enduring blood. To the sound of trumpets shall their seed restore my Cities Wealthy and well-weaponed, that once more may I behold All the world go softly when it walks before my Cities, And the horses and the chariots fleeing from them as of old! -- Rudyard Kipling
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/renames/untimely.txt
Untimely ======== Nothing in life has been made by man for man's using But it was shown long since to man in ages Lost as the name of the maker of it, Who received oppression and shame for his wages-- Hate, avoidance, and scorn in his daily dealings-- Until he perished, wholly confounded More to be pitied than he are the wise Souls which foresaw the evil of loosing Knowledge or Art before time, and aborted Noble devices and deep-wrought healings, Lest offense should arise. Heaven delivers on earth the Hour that cannot be thwarted, Neither advanced, at the price of a world nor a soul, and its Prophet Comes through the blood of the vanguards who dreamed--too soon--it had sounded. -- Rudyard Kipling
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592b/tracked1.txt
You like me
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592b/ignored1.txt
I'm ignored
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592b
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592b/ignored/tracked2.txt
You like me
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592b
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592b/ignored/ignored2.txt
I'm ignored
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592b/ignored
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592b/ignored/contained/ignored3.txt
I'm ignored
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592b/ignored
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/issue_592b/ignored/contained/tracked3.txt
You added me anyhow
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/testrepo2/new.txt
new file
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/testrepo2
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/testrepo2/subdir/new.txt
new file
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/testrepo2/subdir
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/testrepo2/subdir/subdir2/new.txt
new file
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/resources/submod2_target/README.txt
This is the target for submod2 submodule links. Don't add commits casually because you make break tests.
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/transports
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/transports/smart/packet.c
#include "clar_libgit2.h" #include "transports/smart.h" enum expected_status { PARSE_SUCCESS, PARSE_FAILURE }; static void assert_flush_parses(const char *line) { size_t linelen = strlen(line) + 1; const char *endptr; git_pkt *pkt; cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_FLUSH); cl_assert_equal_strn(endptr, line + 4, linelen - 4); git_pkt_free((git_pkt *) pkt); } static void assert_data_pkt_parses(const char *line, const char *expected_data, size_t expected_len) { size_t linelen = strlen(line) + 1; const char *endptr; git_pkt_data *pkt; cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_DATA); cl_assert_equal_i(pkt->len, expected_len); cl_assert_equal_strn(pkt->data, expected_data, expected_len); git_pkt_free((git_pkt *) pkt); } static void assert_sideband_progress_parses(const char *line, const char *expected_data, size_t expected_len) { size_t linelen = strlen(line) + 1; const char *endptr; git_pkt_progress *pkt; cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_PROGRESS); cl_assert_equal_i(pkt->len, expected_len); cl_assert_equal_strn(pkt->data, expected_data, expected_len); git_pkt_free((git_pkt *) pkt); } static void assert_error_parses(const char *line, const char *expected_error, size_t expected_len) { size_t linelen = strlen(line) + 1; const char *endptr; git_pkt_err *pkt; cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_ERR); cl_assert_equal_i(pkt->len, expected_len); cl_assert_equal_strn(pkt->error, expected_error, expected_len); git_pkt_free((git_pkt *) pkt); } static void assert_ack_parses(const char *line, const char *expected_oid, enum git_ack_status expected_status) { size_t linelen = strlen(line) + 1; const char *endptr; git_pkt_ack *pkt; git_oid oid; cl_git_pass(git_oid_fromstr(&oid, expected_oid)); cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_ACK); cl_assert_equal_oid(&pkt->oid, &oid); cl_assert_equal_i(pkt->status, expected_status); git_pkt_free((git_pkt *) pkt); } static void assert_nak_parses(const char *line) { size_t linelen = strlen(line) + 1; const char *endptr; git_pkt *pkt; cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_NAK); cl_assert_equal_strn(endptr, line + 7, linelen - 7); git_pkt_free((git_pkt *) pkt); } static void assert_comment_parses(const char *line, const char *expected_comment) { size_t linelen = strlen(line) + 1; const char *endptr; git_pkt_comment *pkt; cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_COMMENT); cl_assert_equal_strn(pkt->comment, expected_comment, strlen(expected_comment)); git_pkt_free((git_pkt *) pkt); } static void assert_ok_parses(const char *line, const char *expected_ref) { size_t linelen = strlen(line) + 1; const char *endptr; git_pkt_ok *pkt; cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_OK); cl_assert_equal_strn(pkt->ref, expected_ref, strlen(expected_ref)); git_pkt_free((git_pkt *) pkt); } static void assert_unpack_parses(const char *line, bool ok) { size_t linelen = strlen(line) + 1; const char *endptr; git_pkt_unpack *pkt; cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_UNPACK); cl_assert_equal_i(pkt->unpack_ok, ok); git_pkt_free((git_pkt *) pkt); } static void assert_ng_parses(const char *line, const char *expected_ref, const char *expected_msg) { size_t linelen = strlen(line) + 1; const char *endptr; git_pkt_ng *pkt; cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_NG); cl_assert_equal_strn(pkt->ref, expected_ref, strlen(expected_ref)); cl_assert_equal_strn(pkt->msg, expected_msg, strlen(expected_msg)); git_pkt_free((git_pkt *) pkt); } #define assert_ref_parses(line, expected_oid, expected_ref, expected_capabilities) \ assert_ref_parses_(line, sizeof(line), expected_oid, expected_ref, expected_capabilities) static void assert_ref_parses_(const char *line, size_t linelen, const char *expected_oid, const char *expected_ref, const char *expected_capabilities) { const char *endptr; git_pkt_ref *pkt; git_oid oid; cl_git_pass(git_oid_fromstr(&oid, expected_oid)); cl_git_pass(git_pkt_parse_line((git_pkt **) &pkt, &endptr, line, linelen)); cl_assert_equal_i(pkt->type, GIT_PKT_REF); cl_assert_equal_oid(&pkt->head.oid, &oid); cl_assert_equal_strn(pkt->head.name, expected_ref, strlen(expected_ref)); if (expected_capabilities) cl_assert_equal_strn(pkt->capabilities, expected_capabilities, strlen(expected_capabilities)); else cl_assert_equal_p(NULL, pkt->capabilities); git_pkt_free((git_pkt *) pkt); } static void assert_pkt_fails(const char *line) { const char *endptr; git_pkt *pkt; cl_git_fail(git_pkt_parse_line(&pkt, &endptr, line, strlen(line) + 1)); } void test_transports_smart_packet__parsing_garbage_fails(void) { assert_pkt_fails("0foobar"); assert_pkt_fails("00foobar"); assert_pkt_fails("000foobar"); assert_pkt_fails("0001"); assert_pkt_fails(""); assert_pkt_fails("0"); assert_pkt_fails("0i00"); assert_pkt_fails("f"); } void test_transports_smart_packet__flush_parses(void) { assert_flush_parses("0000"); assert_flush_parses("0000foobar"); } void test_transports_smart_packet__data_pkt(void) { assert_pkt_fails("000foobar"); assert_pkt_fails("0001o"); assert_pkt_fails("0001\1"); assert_data_pkt_parses("0005\1", "", 0); assert_pkt_fails("0009\1o"); assert_data_pkt_parses("0009\1data", "data", 4); assert_data_pkt_parses("000a\1data", "data", 5); } void test_transports_smart_packet__sideband_progress_pkt(void) { assert_pkt_fails("0001\2"); assert_sideband_progress_parses("0005\2", "", 0); assert_pkt_fails("0009\2o"); assert_sideband_progress_parses("0009\2data", "data", 4); assert_sideband_progress_parses("000a\2data", "data", 5); } void test_transports_smart_packet__sideband_err_pkt(void) { assert_pkt_fails("0001\3"); assert_error_parses("0005\3", "", 0); assert_pkt_fails("0009\3o"); assert_error_parses("0009\3data", "data", 4); assert_error_parses("000a\3data", "data", 5); } void test_transports_smart_packet__ack_pkt(void) { assert_ack_parses("0030ACK 0000000000000000000000000000000000000000", "0000000000000000000000000000000000000000", 0); assert_ack_parses("0039ACK 0000000000000000000000000000000000000000 continue", "0000000000000000000000000000000000000000", GIT_ACK_CONTINUE); assert_ack_parses("0037ACK 0000000000000000000000000000000000000000 common", "0000000000000000000000000000000000000000", GIT_ACK_COMMON); assert_ack_parses("0037ACK 0000000000000000000000000000000000000000 ready", "0000000000000000000000000000000000000000", GIT_ACK_READY); /* these should fail as they don't have OIDs */ assert_pkt_fails("0007ACK"); assert_pkt_fails("0008ACK "); /* this one is missing a space and should thus fail */ assert_pkt_fails("0036ACK00000000000000000x0000000000000000000000 ready"); /* the following ones have invalid OIDs and should thus fail */ assert_pkt_fails("0037ACK 00000000000000000x0000000000000000000000 ready"); assert_pkt_fails("0036ACK 000000000000000000000000000000000000000 ready"); assert_pkt_fails("0036ACK 00000000000000000x0000000000000000000000ready"); /* this one has an invalid status and should thus fail */ assert_pkt_fails("0036ACK 0000000000000000000000000000000000000000 read"); } void test_transports_smart_packet__nak_pkt(void) { assert_nak_parses("0007NAK"); assert_pkt_fails("0007NaK"); assert_pkt_fails("0007nak"); assert_nak_parses("0007NAKfoobar"); assert_pkt_fails("0007nakfoobar"); assert_pkt_fails("0007 NAK"); } void test_transports_smart_packet__error_pkt(void) { assert_pkt_fails("0007ERR"); assert_pkt_fails("0008ERRx"); assert_error_parses("0008ERR ", "", 0); assert_error_parses("000EERR ERRMSG", "ERRMSG", 6); } void test_transports_smart_packet__comment_pkt(void) { assert_comment_parses("0005#", ""); assert_comment_parses("000B#foobar", "#fooba"); assert_comment_parses("000C#foobar", "#foobar"); assert_comment_parses("001A#this is a comment\nfoo", "#this is a comment\nfoo"); } void test_transports_smart_packet__ok_pkt(void) { assert_pkt_fails("0007ok\n"); assert_ok_parses("0007ok ", ""); assert_ok_parses("0008ok \n", ""); assert_ok_parses("0008ok x", "x"); assert_ok_parses("0009ok x\n", "x"); assert_pkt_fails("001OK ref/foo/bar"); assert_ok_parses("0012ok ref/foo/bar", "ref/foo/bar"); assert_pkt_fails("0013OK ref/foo/bar\n"); assert_ok_parses("0013ok ref/foo/bar\n", "ref/foo/bar"); } void test_transports_smart_packet__ng_pkt(void) { /* TODO: same as for ok pkt */ assert_pkt_fails("0007ng\n"); assert_pkt_fails("0008ng \n"); assert_pkt_fails("000Bng ref\n"); assert_pkt_fails("000Bng ref\n"); /* TODO: is this a valid packet line? Probably not. */ assert_ng_parses("000Ang x\n", "", "x"); assert_ng_parses("000Fng ref msg\n", "ref", "msg"); assert_ng_parses("000Fng ref msg\n", "ref", "msg"); } void test_transports_smart_packet__unpack_pkt(void) { assert_unpack_parses("000Dunpack ok", 1); assert_unpack_parses("000Dunpack ng error-msg", 0); /* TODO: the following tests should fail */ assert_unpack_parses("000Aunpack", 0); assert_unpack_parses("0011unpack foobar", 0); assert_unpack_parses("0010unpack ng ok", 0); assert_unpack_parses("0010unpack okfoo", 1); } void test_transports_smart_packet__ref_pkt(void) { assert_pkt_fails("002C0000000000000000000000000000000000000000"); assert_pkt_fails("002D0000000000000000000000000000000000000000\n"); assert_pkt_fails("00300000000000000000000000000000000000000000HEAD"); assert_pkt_fails("004800000000x0000000000000000000000000000000 refs/heads/master\0multi_ack"); assert_ref_parses( "003F0000000000000000000000000000000000000000 refs/heads/master\0", "0000000000000000000000000000000000000000", "refs/heads/master", ""); assert_ref_parses( "00480000000000000000000000000000000000000000 refs/heads/master\0multi_ack", "0000000000000000000000000000000000000000", "refs/heads/master", "multi_ack"); assert_ref_parses( "00460000000000000000000000000000000000000000 refs/heads/master\0one two", "0000000000000000000000000000000000000000", "refs/heads/master", "one two"); assert_ref_parses( "00310000000000000000000000000000000000000000 HEAD", "0000000000000000000000000000000000000000", "HEAD", NULL); assert_pkt_fails("0031000000000000000000000000000000000000000 HEAD"); assert_ref_parses( "00360000000000000000000000000000000000000000 HEAD HEAD", "0000000000000000000000000000000000000000", "HEAD HEAD", NULL); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/patch/print.c
#include "clar_libgit2.h" #include "patch.h" #include "patch_parse.h" #include "patch_common.h" /* sanity check the round-trip of patch parsing: ensure that we can parse * and then print a variety of patch files. */ void patch_print_from_patchfile(const char *data, size_t len) { git_patch *patch; git_buf buf = GIT_BUF_INIT; cl_git_pass(git_patch_from_buffer(&patch, data, len, NULL)); cl_git_pass(git_patch_to_buf(&buf, patch)); cl_assert_equal_s(data, buf.ptr); git_patch_free(patch); git_buf_dispose(&buf); } void test_patch_print__change_middle(void) { patch_print_from_patchfile(PATCH_ORIGINAL_TO_CHANGE_MIDDLE, strlen(PATCH_ORIGINAL_TO_CHANGE_MIDDLE)); } void test_patch_print__change_middle_nocontext(void) { patch_print_from_patchfile(PATCH_ORIGINAL_TO_CHANGE_MIDDLE_NOCONTEXT, strlen(PATCH_ORIGINAL_TO_CHANGE_MIDDLE_NOCONTEXT)); } void test_patch_print__change_firstline(void) { patch_print_from_patchfile(PATCH_ORIGINAL_TO_CHANGE_FIRSTLINE, strlen(PATCH_ORIGINAL_TO_CHANGE_FIRSTLINE)); } void test_patch_print__change_lastline(void) { patch_print_from_patchfile(PATCH_ORIGINAL_TO_CHANGE_LASTLINE, strlen(PATCH_ORIGINAL_TO_CHANGE_LASTLINE)); } void test_patch_print__prepend(void) { patch_print_from_patchfile(PATCH_ORIGINAL_TO_PREPEND, strlen(PATCH_ORIGINAL_TO_PREPEND)); } void test_patch_print__prepend_nocontext(void) { patch_print_from_patchfile(PATCH_ORIGINAL_TO_PREPEND_NOCONTEXT, strlen(PATCH_ORIGINAL_TO_PREPEND_NOCONTEXT)); } void test_patch_print__append(void) { patch_print_from_patchfile(PATCH_ORIGINAL_TO_APPEND, strlen(PATCH_ORIGINAL_TO_APPEND)); } void test_patch_print__append_nocontext(void) { patch_print_from_patchfile(PATCH_ORIGINAL_TO_APPEND_NOCONTEXT, strlen(PATCH_ORIGINAL_TO_APPEND_NOCONTEXT)); } void test_patch_print__prepend_and_append(void) { patch_print_from_patchfile(PATCH_ORIGINAL_TO_PREPEND_AND_APPEND, strlen(PATCH_ORIGINAL_TO_PREPEND_AND_APPEND)); } void test_patch_print__to_empty_file(void) { patch_print_from_patchfile(PATCH_ORIGINAL_TO_EMPTY_FILE, strlen(PATCH_ORIGINAL_TO_EMPTY_FILE)); } void test_patch_print__from_empty_file(void) { patch_print_from_patchfile(PATCH_EMPTY_FILE_TO_ORIGINAL, strlen(PATCH_EMPTY_FILE_TO_ORIGINAL)); } void test_patch_print__add(void) { patch_print_from_patchfile(PATCH_ADD_ORIGINAL, strlen(PATCH_ADD_ORIGINAL)); } void test_patch_print__delete(void) { patch_print_from_patchfile(PATCH_DELETE_ORIGINAL, strlen(PATCH_DELETE_ORIGINAL)); } void test_patch_print__rename_exact(void) { patch_print_from_patchfile(PATCH_RENAME_EXACT, strlen(PATCH_RENAME_EXACT)); } void test_patch_print__rename_exact_with_mode(void) { patch_print_from_patchfile(PATCH_RENAME_EXACT_WITH_MODE, strlen(PATCH_RENAME_EXACT_WITH_MODE)); } void test_patch_print__rename_similar(void) { patch_print_from_patchfile(PATCH_RENAME_SIMILAR, strlen(PATCH_RENAME_SIMILAR)); } void test_patch_print__rename_exact_quotedname(void) { patch_print_from_patchfile(PATCH_RENAME_EXACT_QUOTEDNAME, strlen(PATCH_RENAME_EXACT_QUOTEDNAME)); } void test_patch_print__rename_similar_quotedname(void) { patch_print_from_patchfile(PATCH_RENAME_SIMILAR_QUOTEDNAME, strlen(PATCH_RENAME_SIMILAR_QUOTEDNAME)); } void test_patch_print__modechange_unchanged(void) { patch_print_from_patchfile(PATCH_MODECHANGE_UNCHANGED, strlen(PATCH_MODECHANGE_UNCHANGED)); } void test_patch_print__modechange_modified(void) { patch_print_from_patchfile(PATCH_MODECHANGE_MODIFIED, strlen(PATCH_MODECHANGE_MODIFIED)); } void test_patch_print__binary_literal(void) { patch_print_from_patchfile(PATCH_BINARY_LITERAL, strlen(PATCH_BINARY_LITERAL)); } void test_patch_print__binary_delta(void) { patch_print_from_patchfile(PATCH_BINARY_DELTA, strlen(PATCH_BINARY_DELTA)); } void test_patch_print__binary_add(void) { patch_print_from_patchfile(PATCH_BINARY_ADD, strlen(PATCH_BINARY_ADD)); } void test_patch_print__binary_delete(void) { patch_print_from_patchfile(PATCH_BINARY_DELETE, strlen(PATCH_BINARY_DELETE)); } void test_patch_print__not_reversible(void) { patch_print_from_patchfile(PATCH_BINARY_NOT_REVERSIBLE, strlen(PATCH_BINARY_NOT_REVERSIBLE)); } void test_patch_print__binary_not_shown(void) { patch_print_from_patchfile(PATCH_BINARY_NOT_PRINTED, strlen(PATCH_BINARY_NOT_PRINTED)); } void test_patch_print__binary_add_not_shown(void) { patch_print_from_patchfile(PATCH_ADD_BINARY_NOT_PRINTED, strlen(PATCH_ADD_BINARY_NOT_PRINTED)); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/patch/patch_common.h
/* The original file contents */ #define FILE_ORIGINAL \ "hey!\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(this line is changed)\n" \ "and this\n" \ "is additional context\n" \ "below it!\n" /* A change in the middle of the file (and the resultant patch) */ #define FILE_CHANGE_MIDDLE \ "hey!\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(THIS line is changed!)\n" \ "and this\n" \ "is additional context\n" \ "below it!\n" #define PATCH_ORIGINAL_TO_CHANGE_MIDDLE \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..cd8fd12 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -3,7 +3,7 @@ this is some context!\n" \ " around some lines\n" \ " that will change\n" \ " yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" #define PATCH_ORIGINAL_TO_CHANGE_MIDDLE_NOCONTEXT \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..cd8fd12 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -6 +6 @@ yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" /* A change of the first line (and the resultant patch) */ #define FILE_CHANGE_FIRSTLINE \ "hey, change in head!\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(this line is changed)\n" \ "and this\n" \ "is additional context\n" \ "below it!\n" #define PATCH_ORIGINAL_TO_CHANGE_FIRSTLINE \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..c81df1d 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -1,4 +1,4 @@\n" \ "-hey!\n" \ "+hey, change in head!\n" \ " this is some context!\n" \ " around some lines\n" \ " that will change\n" /* A change of the last line (and the resultant patch) */ #define FILE_CHANGE_LASTLINE \ "hey!\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(this line is changed)\n" \ "and this\n" \ "is additional context\n" \ "change to the last line.\n" #define PATCH_ORIGINAL_TO_CHANGE_LASTLINE \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..f70db1c 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -6,4 +6,4 @@ yes it is!\n" \ " (this line is changed)\n" \ " and this\n" \ " is additional context\n" \ "-below it!\n" \ "+change to the last line.\n" /* A change of the middle where we remove many lines */ #define FILE_CHANGE_MIDDLE_SHRINK \ "hey!\n" \ "i've changed a lot, but left the line\n" \ "below it!\n" #define PATCH_ORIGINAL_TO_CHANGE_MIDDLE_SHRINK \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..629cd35 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -1,9 +1,3 @@\n" \ " hey!\n" \ "-this is some context!\n" \ "-around some lines\n" \ "-that will change\n" \ "-yes it is!\n" \ "-(this line is changed)\n" \ "-and this\n" \ "-is additional context\n" \ "+i've changed a lot, but left the line\n" \ " below it!\n" #define PATCH_ORIGINAL_TO_MIDDLE_SHRINK_NOCONTEXT \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..629cd35 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -2,7 +2 @@ hey!\n" \ "-this is some context!\n" \ "-around some lines\n" \ "-that will change\n" \ "-yes it is!\n" \ "-(this line is changed)\n" \ "-and this\n" \ "-is additional context\n" \ "+i've changed a lot, but left the line\n" /* A change to the middle where we grow many lines */ #define FILE_CHANGE_MIDDLE_GROW \ "hey!\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "this line is changed\n" \ "and this line is added\n" \ "so is this\n" \ "(this too)\n" \ "whee...\n" \ "and this\n" \ "is additional context\n" \ "below it!\n" #define PATCH_ORIGINAL_TO_CHANGE_MIDDLE_GROW \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..207ebca 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -3,7 +3,11 @@ this is some context!\n" \ " around some lines\n" \ " that will change\n" \ " yes it is!\n" \ "-(this line is changed)\n" \ "+this line is changed\n" \ "+and this line is added\n" \ "+so is this\n" \ "+(this too)\n" \ "+whee...\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" #define PATCH_ORIGINAL_TO_MIDDLE_GROW_NOCONTEXT \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..207ebca 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -6 +6,5 @@ yes it is!\n" \ "-(this line is changed)\n" \ "+this line is changed\n" \ "+and this line is added\n" \ "+so is this\n" \ "+(this too)\n" \ "+whee...\n" /* An insertion at the beginning of the file (and the resultant patch) */ #define FILE_PREPEND \ "insert at front\n" \ "hey!\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(this line is changed)\n" \ "and this\n" \ "is additional context\n" \ "below it!\n" #define PATCH_ORIGINAL_TO_PREPEND \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..0f39b9a 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -1,3 +1,4 @@\n" \ "+insert at front\n" \ " hey!\n" \ " this is some context!\n" \ " around some lines\n" #define PATCH_ORIGINAL_TO_PREPEND_NOCONTEXT \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..0f39b9a 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -0,0 +1 @@\n" \ "+insert at front\n" /* An insertion at the beginning of the file and change in the middle */ #define FILE_PREPEND_AND_CHANGE \ "insert at front\n" \ "hey!\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(THIS line is changed!)\n" \ "and this\n" \ "is additional context\n" \ "below it!\n" #define PATCH_ORIGINAL_TO_PREPEND_AND_CHANGE \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..f73c8bb 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -1,9 +1,10 @@\n" \ "+insert at front\n" \ " hey!\n" \ " this is some context!\n" \ " around some lines\n" \ " that will change\n" \ " yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" #define PATCH_ORIGINAL_TO_PREPEND_AND_CHANGE_NOCONTEXT \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..f73c8bb 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -0,0 +1 @@\n" \ "+insert at front\n" \ "@@ -6 +7 @@ yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" /* A change in the middle and a deletion of the newline at the end of the file */ #define FILE_CHANGE_MIDDLE_AND_LASTLINE \ "hey!\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(THIS line is changed!)\n" \ "and this\n" \ "is additional context\n" \ "BELOW it! - (THIS line is changed!)" #define PATCH_ORIGINAL_TO_CHANGE_MIDDLE_AND_LASTLINE_NOCONTEXT \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..e05d36c 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -6 +6 @@ yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" \ "@@ -9 +9 @@ is additional context\n" \ "-below it!\n" \ "+BELOW it! - (THIS line is changed!)\n" \ "\\ No newline at end of file\n" /* A deletion at the beginning of the file and a change in the middle */ #define FILE_DELETE_AND_CHANGE \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(THIS line is changed!)\n" \ "and this\n" \ "is additional context\n" \ "below it!\n" #define PATCH_ORIGINAL_TO_DELETE_AND_CHANGE \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..1e2dfa6 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -1,9 +1,8 @@\n" \ "-hey!\n" \ " this is some context!\n" \ " around some lines\n" \ " that will change\n" \ " yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" #define PATCH_ORIGINAL_TO_DELETE_AND_CHANGE_NOCONTEXT \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..1e2dfa6 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -1 +0,0 @@\n" \ "-hey!\n" \ "@@ -6 +5 @@ yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" /* A deletion at the beginning of the file */ #define FILE_DELETE_FIRSTLINE \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(this line is changed)\n" \ "and this\n" \ "is additional context\n" \ "below it!\n" #define PATCH_ORIGINAL_TO_DELETE_FIRSTLINE \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..f31fa13 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -1,4 +1,3 @@\n" \ "-hey!\n" \ " this is some context!\n" \ " around some lines\n" \ " that will change\n" /* An insertion at the end of the file (and the resultant patch) */ #define FILE_APPEND \ "hey!\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(this line is changed)\n" \ "and this\n" \ "is additional context\n" \ "below it!\n" \ "insert at end\n" #define PATCH_ORIGINAL_TO_APPEND \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..72788bb 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -7,3 +7,4 @@ yes it is!\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" \ "+insert at end\n" #define PATCH_ORIGINAL_TO_APPEND_NOCONTEXT \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..72788bb 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -9,0 +10 @@ below it!\n" \ "+insert at end\n" #define PATCH_DELETED_FILE_2_HUNKS \ "diff --git a/a b/a\n" \ "index 7f129fd..af431f2 100644\n" \ "--- a/a\n" \ "+++ b/a\n" \ "@@ -1 +1 @@\n" \ "-a contents 2\n" \ "+a contents\n" \ "diff --git a/c/d b/c/d\n" \ "deleted file mode 100644\n" \ "index 297efb8..0000000\n" \ "--- a/c/d\n" \ "+++ /dev/null\n" \ "@@ -1 +0,0 @@\n" \ "-c/d contents\n" #define PATCH_DELETED_FILE_2_HUNKS_SHUFFLED \ "diff --git a/c/d b/c/d\n" \ "deleted file mode 100644\n" \ "index 297efb8..0000000\n" \ "--- a/c/d\n" \ "+++ /dev/null\n" \ "@@ -1 +0,0 @@\n" \ "-c/d contents\n" \ "diff --git a/a b/a\n" \ "index 7f129fd..af431f2 100644\n" \ "--- a/a\n" \ "+++ b/a\n" \ "@@ -1 +1 @@\n" \ "-a contents 2\n" \ "+a contents\n" #define PATCH_SIMPLE_COMMIT \ "commit 15e119375018fba121cf58e02a9f17fe22df0df8\n" \ "Author: Edward Thomson <[email protected]>\n" \ "Date: Wed Jun 14 13:31:20 2017 +0200\n" \ "\n" \ " CHANGELOG: document git_filter_init and GIT_FILTER_INIT\n" \ "\n" \ "diff --git a/CHANGELOG.md b/CHANGELOG.md\n" \ "index 1b9e0c90a..24ecba426 100644\n" \ "--- a/CHANGELOG.md\n" \ "+++ b/CHANGELOG.md\n" \ "@@ -96,6 +96,9 @@ v0.26\n" \ " * `git_transport_smart_proxy_options()' enables you to get the proxy options for\n" \ " smart transports.\n" \ "\n" \ "+* The `GIT_FILTER_INIT` macro and the `git_filter_init` function are provided\n" \ "+ to initialize a `git_filter` structure.\n" \ "+\n" \ " ### Breaking API changes\n" \ "\n" \ " * `clone_checkout_strategy` has been removed from\n" #define PATCH_MULTIPLE_HUNKS \ "diff --git a/x b/x\n" \ "index 0719398..fa0350c 100644\n" \ "--- a/x\n" \ "+++ b/x\n" \ "@@ -1,5 +1,4 @@\n" \ " 1\n" \ "-2\n" \ " 3\n" \ " 4\n" \ " 5\n" \ "@@ -7,3 +6,4 @@\n" \ " 7\n" \ " 8\n" \ " 9\n" \ "+10\n" #define PATCH_MULTIPLE_FILES \ "diff --git a/x b/x\n" \ "index 8a1218a..7059ba5 100644\n" \ "--- a/x\n" \ "+++ b/x\n" \ "@@ -1,5 +1,4 @@\n" \ " 1\n" \ " 2\n" \ "-3\n" \ " 4\n" \ " 5\n" \ "diff --git a/y b/y\n" \ "index e006065..9405325 100644\n" \ "--- a/y\n" \ "+++ b/y\n" \ "@@ -1,4 +1,5 @@\n" \ " a\n" \ " b\n" \ "+c\n" \ " d\n" \ " e\n" #define FILE_PREPEND_AND_APPEND \ "first and\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(this line is changed)\n" \ "and this\n" \ "is additional context\n" \ "last lines\n" #define PATCH_ORIGINAL_TO_PREPEND_AND_APPEND \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..f282430 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -1,4 +1,4 @@\n" \ "-hey!\n" \ "+first and\n" \ " this is some context!\n" \ " around some lines\n" \ " that will change\n" \ "@@ -6,4 +6,4 @@ yes it is!\n" \ " (this line is changed)\n" \ " and this\n" \ " is additional context\n" \ "-below it!\n" \ "+last lines\n" #define PATCH_ORIGINAL_TO_EMPTY_FILE \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..e69de29 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -1,9 +0,0 @@\n" \ "-hey!\n" \ "-this is some context!\n" \ "-around some lines\n" \ "-that will change\n" \ "-yes it is!\n" \ "-(this line is changed)\n" \ "-and this\n" \ "-is additional context\n" \ "-below it!\n" #define PATCH_EMPTY_FILE_TO_ORIGINAL \ "diff --git a/file.txt b/file.txt\n" \ "index e69de29..9432026 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -0,0 +1,9 @@\n" \ "+hey!\n" \ "+this is some context!\n" \ "+around some lines\n" \ "+that will change\n" \ "+yes it is!\n" \ "+(this line is changed)\n" \ "+and this\n" \ "+is additional context\n" \ "+below it!\n" #define PATCH_ADD_ORIGINAL \ "diff --git a/file.txt b/file.txt\n" \ "new file mode 100644\n" \ "index 0000000..9432026\n" \ "--- /dev/null\n" \ "+++ b/file.txt\n" \ "@@ -0,0 +1,9 @@\n" \ "+hey!\n" \ "+this is some context!\n" \ "+around some lines\n" \ "+that will change\n" \ "+yes it is!\n" \ "+(this line is changed)\n" \ "+and this\n" \ "+is additional context\n" \ "+below it!\n" #define PATCH_DELETE_ORIGINAL \ "diff --git a/file.txt b/file.txt\n" \ "deleted file mode 100644\n" \ "index 9432026..0000000\n" \ "--- a/file.txt\n" \ "+++ /dev/null\n" \ "@@ -1,9 +0,0 @@\n" \ "-hey!\n" \ "-this is some context!\n" \ "-around some lines\n" \ "-that will change\n" \ "-yes it is!\n" \ "-(this line is changed)\n" \ "-and this\n" \ "-is additional context\n" \ "-below it!\n" #define PATCH_RENAME_EXACT \ "diff --git a/file.txt b/newfile.txt\n" \ "similarity index 100%\n" \ "rename from file.txt\n" \ "rename to newfile.txt\n" #define PATCH_RENAME_EXACT_WITH_MODE \ "diff --git a/RENAMED.md b/README.md\n" \ "old mode 100644\n" \ "new mode 100755\n" \ "similarity index 100%\n" \ "rename from RENAMED.md\n" \ "rename to README.md\n" #define PATCH_RENAME_SIMILAR \ "diff --git a/file.txt b/newfile.txt\n" \ "similarity index 77%\n" \ "rename from file.txt\n" \ "rename to newfile.txt\n" \ "index 9432026..cd8fd12 100644\n" \ "--- a/file.txt\n" \ "+++ b/newfile.txt\n" \ "@@ -3,7 +3,7 @@ this is some context!\n" \ " around some lines\n" \ " that will change\n" \ " yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" #define PATCH_RENAME_EXACT_QUOTEDNAME \ "diff --git a/file.txt \"b/foo\\\"bar.txt\"\n" \ "similarity index 100%\n" \ "rename from file.txt\n" \ "rename to \"foo\\\"bar.txt\"\n" #define PATCH_RENAME_SIMILAR_QUOTEDNAME \ "diff --git a/file.txt \"b/foo\\\"bar.txt\"\n" \ "similarity index 77%\n" \ "rename from file.txt\n" \ "rename to \"foo\\\"bar.txt\"\n" \ "index 9432026..cd8fd12 100644\n" \ "--- a/file.txt\n" \ "+++ \"b/foo\\\"bar.txt\"\n" \ "@@ -3,7 +3,7 @@ this is some context!\n" \ " around some lines\n" \ " that will change\n" \ " yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" #define PATCH_MODECHANGE_UNCHANGED \ "diff --git a/file.txt b/file.txt\n" \ "old mode 100644\n" \ "new mode 100755\n" #define PATCH_MODECHANGE_MODIFIED \ "diff --git a/file.txt b/file.txt\n" \ "old mode 100644\n" \ "new mode 100755\n" \ "index 9432026..cd8fd12\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -3,7 +3,7 @@ this is some context!\n" \ " around some lines\n" \ " that will change\n" \ " yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" #define PATCH_NOISY \ "This is some\nleading noise\n@@ - that\nlooks like a hunk header\n" \ "but actually isn't and should parse ok\n" \ PATCH_ORIGINAL_TO_CHANGE_MIDDLE \ "plus some trailing garbage for good measure\n" #define PATCH_NOISY_NOCONTEXT \ "This is some\nleading noise\n@@ - that\nlooks like a hunk header\n" \ "but actually isn't and should parse ok\n" \ PATCH_ORIGINAL_TO_CHANGE_MIDDLE_NOCONTEXT \ "plus some trailing garbage for good measure\n" #define PATCH_TRUNCATED_1 \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..cd8fd12 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -3,7 +3,7 @@ this is some context!\n" \ " around some lines\n" \ " that will change\n" \ " yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" \ " and this\n" #define PATCH_TRUNCATED_2 \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..cd8fd12 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -3,7 +3,7 @@ this is some context!\n" \ " around some lines\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" #define PATCH_TRUNCATED_3 \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..cd8fd12 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -3,7 +3,7 @@ this is some context!\n" \ " around some lines\n" \ " that will change\n" \ " yes it is!\n" \ "+(THIS line is changed!)\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" #define FILE_EMPTY_CONTEXT_ORIGINAL \ "this\nhas\nan\n\nempty\ncontext\nline\n" #define FILE_EMPTY_CONTEXT_MODIFIED \ "this\nhas\nan\n\nempty...\ncontext\nline\n" #define PATCH_EMPTY_CONTEXT \ "diff --git a/file.txt b/file.txt\n" \ "index 398d2df..bb15234 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -2,6 +2,6 @@ this\n" \ " has\n" \ " an\n" \ "\n" \ "-empty\n" \ "+empty...\n" \ " context\n" \ " line\n" #define FILE_APPEND_NO_NL \ "hey!\n" \ "this is some context!\n" \ "around some lines\n" \ "that will change\n" \ "yes it is!\n" \ "(this line is changed)\n" \ "and this\n" \ "is additional context\n" \ "below it!\n" \ "added line with no nl" #define PATCH_APPEND_NO_NL \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..83759c0 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -7,3 +7,4 @@ yes it is!\n" \ " and this\n" \ " is additional context\n" \ " below it!\n" \ "+added line with no nl\n" \ "\\ No newline at end of file\n" #define PATCH_APPEND_NO_NL_IN_OLD_FILE \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..83759c0 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -1,1 +1,1 @@\n" \ "-foo\n" \ "\\ No newline at end of file\n" \ "+foo\n" #define PATCH_NAME_WHITESPACE \ "diff --git a/file with spaces.txt b/file with spaces.txt\n" \ "index 9432026..83759c0 100644\n" \ "--- a/file with spaces.txt\n" \ "+++ b/file with spaces.txt\n" \ "@@ -0,3 +0,2 @@\n" \ " and this\n" \ "-is additional context\n" \ " below it!\n" \ #define PATCH_CORRUPT_GIT_HEADER \ "diff --git a/file.txt\n" \ "index 9432026..0f39b9a 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -0,0 +1 @@\n" \ "+insert at front\n" #define PATCH_CORRUPT_MISSING_NEW_FILE \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..cd8fd12 100644\n" \ "--- a/file.txt\n" \ "@@ -6 +6 @@ yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" #define PATCH_CORRUPT_MISSING_OLD_FILE \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..cd8fd12 100644\n" \ "+++ b/file.txt\n" \ "@@ -6 +6 @@ yes it is!\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" #define PATCH_CORRUPT_NO_CHANGES \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..cd8fd12 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "@@ -0,0 +0,0 @@ yes it is!\n" #define PATCH_CORRUPT_MISSING_HUNK_HEADER \ "diff --git a/file.txt b/file.txt\n" \ "index 9432026..cd8fd12 100644\n" \ "--- a/file.txt\n" \ "+++ b/file.txt\n" \ "-(this line is changed)\n" \ "+(THIS line is changed!)\n" #define PATCH_NOT_A_PATCH \ "+++this is not\n" \ "--actually even\n" \ " a legitimate \n" \ "+patch file\n" \ "-it's something else\n" \ " entirely!" /* binary contents */ #define FILE_BINARY_LITERAL_ORIGINAL "\x00\x00\x0a" #define FILE_BINARY_LITERAL_ORIGINAL_LEN 3 #define FILE_BINARY_LITERAL_MODIFIED "\x00\x00\x01\x02\x0a" #define FILE_BINARY_LITERAL_MODIFIED_LEN 5 #define PATCH_BINARY_LITERAL \ "diff --git a/binary.bin b/binary.bin\n" \ "index bd474b2519cc15eab801ff851cc7d50f0dee49a1..9ac35ff15cd8864aeafd889e4826a3150f0b06c4 100644\n" \ "GIT binary patch\n" \ "literal 5\n" \ "Mc${NkU}WL~000&M4gdfE\n" \ "\n" \ "literal 3\n" \ "Kc${Nk-~s>u4FC%O\n\n" #define FILE_BINARY_DELTA_ORIGINAL \ "\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02\x0a\x54\x68\x69" \ "\x73\x20\x69\x73\x20\x61\x20\x62\x69\x6e\x61\x72\x79\x20\x66\x69" \ "\x6c\x65\x2c\x20\x62\x79\x20\x76\x69\x72\x74\x75\x65\x20\x6f\x66" \ "\x20\x68\x61\x76\x69\x6e\x67\x20\x73\x6f\x6d\x65\x20\x6e\x75\x6c" \ "\x6c\x73\x2e\x0a\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02" \ "\x0a\x57\x65\x27\x72\x65\x20\x67\x6f\x69\x6e\x67\x20\x74\x6f\x20" \ "\x63\x68\x61\x6e\x67\x65\x20\x70\x6f\x72\x74\x69\x6f\x6e\x73\x20" \ "\x6f\x66\x20\x69\x74\x2e\x0a\x00\x00\x01\x02\x00\x00\x01\x02\x00" \ "\x00\x01\x02\x0a\x53\x6f\x20\x74\x68\x61\x74\x20\x77\x65\x20\x67" \ "\x69\x74\x20\x61\x20\x62\x69\x6e\x61\x72\x79\x20\x64\x65\x6c\x74" \ "\x61\x20\x69\x6e\x73\x74\x65\x61\x64\x20\x6f\x66\x20\x74\x68\x65" \ "\x20\x64\x65\x66\x6c\x61\x74\x65\x64\x20\x63\x6f\x6e\x74\x65\x6e" \ "\x74\x73\x2e\x0a\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02" \ "\x0a" #define FILE_BINARY_DELTA_ORIGINAL_LEN 209 #define FILE_BINARY_DELTA_MODIFIED \ "\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02\x0a\x5a\x5a\x5a" \ "\x5a\x20\x69\x73\x20\x61\x20\x62\x69\x6e\x61\x72\x79\x20\x66\x69" \ "\x6c\x65\x2c\x20\x62\x79\x20\x76\x69\x72\x74\x75\x65\x20\x6f\x66" \ "\x20\x68\x61\x76\x69\x6e\x67\x20\x73\x6f\x6d\x65\x20\x6e\x75\x6c" \ "\x6c\x73\x2e\x0a\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02" \ "\x0a\x57\x65\x27\x72\x65\x20\x67\x6f\x69\x6e\x67\x20\x74\x6f\x20" \ "\x63\x68\x61\x6e\x67\x65\x20\x70\x6f\x72\x74\x69\x6f\x6e\x73\x20" \ "\x6f\x66\x20\x49\x54\x2e\x0a\x00\x00\x01\x02\x00\x00\x01\x02\x00" \ "\x00\x01\x02\x0a\x53\x4f\x20\x74\x68\x61\x74\x20\x77\x65\x20\x67" \ "\x69\x74\x20\x61\x20\x62\x69\x6e\x61\x72\x79\x20\x64\x65\x6c\x74" \ "\x61\x20\x69\x6e\x73\x74\x65\x61\x64\x20\x6f\x66\x20\x74\x68\x65" \ "\x20\x64\x65\x66\x6c\x61\x74\x65\x64\x20\x63\x6f\x6e\x74\x65\x6e" \ "\x74\x73\x2e\x0a\x00\x00\x01\x02\x00\x00\x01\x02\x00\x00\x01\x02" \ "\x0a" #define FILE_BINARY_DELTA_MODIFIED_LEN 209 #define PATCH_BINARY_DELTA \ "diff --git a/binary.bin b/binary.bin\n" \ "index 27184d9883b12c4c9c54b4a31137603586169f51..7c94f9e60bf366033d98e0d551ae37d30faef74a 100644\n" \ "GIT binary patch\n" \ "delta 48\n" \ "kc$~Y)c#%<%fq{_;hPk4EV4`4>uxE%K7m7r%|HL+L0In7XGynhq\n" \ "\n" \ "delta 48\n" \ "mc$~Y)c#%<%fq{_;hPgsAGK(h)CJASj=y9P)1m{m|^9BI99|yz$\n\n" #define PATCH_BINARY_ADD \ "diff --git a/binary.bin b/binary.bin\n" \ "new file mode 100644\n" \ "index 0000000000000000000000000000000000000000..7c94f9e60bf366033d98e0d551ae37d30faef74a\n" \ "GIT binary patch\n" \ "literal 209\n" \ "zc${60u?oUK5JXSQe8qG&;(u6KC<u0&+$Ohh?#kUJlD{_rLCL^0!@QXgcKh&k^H>C_\n" \ "zAhe=XX7rNzh<3&##YcwqNHmEKsP<&&m~%Zf;eX@Khr$?aExDmfqyyt+#l^I)3+LMg\n" \ "kxnAIj9Pfn_|Gh`fP7tlm6j#y{FJYg_IifRlR^R@A08f862mk;8\n" \ "\n" \ "literal 0\n" \ "Hc$@<O00001\n\n" #define PATCH_BINARY_DELETE \ "diff --git a/binary.bin b/binary.bin\n" \ "deleted file mode 100644\n" \ "index 7c94f9e60bf366033d98e0d551ae37d30faef74a..0000000000000000000000000000000000000000\n" \ "GIT binary patch\n" \ "literal 0\n" \ "Hc$@<O00001\n" \ "\n" \ "literal 209\n" \ "zc${60u?oUK5JXSQe8qG&;(u6KC<u0&+$Ohh?#kUJlD{_rLCL^0!@QXgcKh&k^H>C_\n" \ "zAhe=XX7rNzh<3&##YcwqNHmEKsP<&&m~%Zf;eX@Khr$?aExDmfqyyt+#l^I)3+LMg\n" \ "kxnAIj9Pfn_|Gh`fP7tlm6j#y{FJYg_IifRlR^R@A08f862mk;8\n\n" /* contains an old side that does not match the expected source */ #define PATCH_BINARY_NOT_REVERSIBLE \ "diff --git a/binary.bin b/binary.bin\n" \ "index 27184d9883b12c4c9c54b4a31137603586169f51..7c94f9e60bf366033d98e0d551ae37d30faef74a 100644\n" \ "GIT binary patch\n" \ "literal 5\n" \ "Mc${NkU}WL~000&M4gdfE\n" \ "\n" \ "delta 48\n" \ "mc$~Y)c#%<%fq{_;hPgsAGK(h)CJASj=y9P)1m{m|^9BI99|yz$\n\n" #define PATCH_BINARY_NOT_PRINTED \ "diff --git a/binary.bin b/binary.bin\n" \ "index 27184d9..7c94f9e 100644\n" \ "Binary files a/binary.bin and b/binary.bin differ\n" #define PATCH_ADD_BINARY_NOT_PRINTED \ "diff --git a/test.bin b/test.bin\n" \ "new file mode 100644\n" \ "index 0000000..9e0f96a\n" \ "Binary files /dev/null and b/test.bin differ\n" #define PATCH_ORIGINAL_NEW_FILE_WITH_SPACE \ "diff --git a/sp ace.txt b/sp ace.txt\n" \ "new file mode 100644\n" \ "index 000000000..789819226\n" \ "--- /dev/null\n" \ "+++ b/sp ace.txt\n" \ "@@ -0,0 +1 @@\n" \ "+a\n" #define PATCH_CRLF \ "diff --git a/test-file b/test-file\r\n" \ "new file mode 100644\r\n" \ "index 0000000..af431f2 100644\r\n" \ "--- /dev/null\r\n" \ "+++ b/test-file\r\n" \ "@@ -0,0 +1 @@\r\n" \ "+a contents\r\n" #define PATCH_NO_EXTENDED_HEADERS \ "diff --git a/file b/file\n" \ "--- a/file\n" \ "+++ b/file\n" \ "@@ -1,3 +1,3 @@\n" \ " a\n" \ "-b\n" \ "+bb\n" \ " c\n" #define PATCH_BINARY_FILE_WITH_MISSING_PATHS \ "diff --git \n" \ "--- \n" \ "+++ \n" \ "Binary files " #define PATCH_BINARY_FILE_WITH_WHITESPACE_PATHS \ "diff --git a/file b/file\n" \ "--- \n" \ "+++ \n" \ "Binary files " #define PATCH_BINARY_FILE_WITH_QUOTED_EMPTY_PATHS \ "diff --git a/file b/file\n" \ "--- \"\"\n" \ "+++ \"\"\n" \ "Binary files " #define PATCH_BINARY_FILE_PATH_WITH_SPACES \ "diff --git a b c d e f\n" \ "--- a b c\n" \ "+++ d e f\n" \ "Binary files a b c and d e f differ" #define PATCH_BINARY_FILE_PATH_WITHOUT_BODY_PATHS \ "diff --git a b c d e f\n" \ "--- \n" \ "+++ \n" \ "Binary files a b c and d e f differ" #define PATCH_BINARY_FILE_WITH_TRUNCATED_DELTA \ "diff --git a/file b/file\n" \ "index 1420..b71f\n" \ "GIT binary patch\n" \ "delta 7\n" \ "d" #define PATCH_MULTIPLE_OLD_PATHS \ "diff --git \n" \ "--- \n" \ "+++ \n" \ "index 0000..7DDb\n" \ "--- \n" #define PATCH_INTMAX_NEW_LINES \ "diff --git a/file b/file\n" \ "--- a/file\n" \ "+++ b/file\n" \ "@@ -0 +2147483647 @@\n" \ "\n" \ " "
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/patch/parse.c
#include "clar_libgit2.h" #include "patch.h" #include "patch_parse.h" #include "patch_common.h" static void ensure_patch_validity(git_patch *patch) { const git_diff_delta *delta; char idstr[GIT_OID_HEXSZ+1] = {0}; cl_assert((delta = git_patch_get_delta(patch)) != NULL); cl_assert_equal_i(2, delta->nfiles); cl_assert_equal_s(delta->old_file.path, "file.txt"); cl_assert(delta->old_file.mode == GIT_FILEMODE_BLOB); cl_assert_equal_i(7, delta->old_file.id_abbrev); git_oid_nfmt(idstr, delta->old_file.id_abbrev, &delta->old_file.id); cl_assert_equal_s(idstr, "9432026"); cl_assert_equal_i(0, delta->old_file.size); cl_assert_equal_s(delta->new_file.path, "file.txt"); cl_assert(delta->new_file.mode == GIT_FILEMODE_BLOB); cl_assert_equal_i(7, delta->new_file.id_abbrev); git_oid_nfmt(idstr, delta->new_file.id_abbrev, &delta->new_file.id); cl_assert_equal_s(idstr, "cd8fd12"); cl_assert_equal_i(0, delta->new_file.size); } static void ensure_identical_patch_inout(const char *content) { git_buf buf = GIT_BUF_INIT; git_patch *patch; cl_git_pass(git_patch_from_buffer(&patch, content, strlen(content), NULL)); cl_git_pass(git_patch_to_buf(&buf, patch)); cl_assert_equal_strn(git_buf_cstr(&buf), content, strlen(content)); git_patch_free(patch); git_buf_dispose(&buf); } void test_patch_parse__original_to_change_middle(void) { git_patch *patch; cl_git_pass(git_patch_from_buffer( &patch, PATCH_ORIGINAL_TO_CHANGE_MIDDLE, strlen(PATCH_ORIGINAL_TO_CHANGE_MIDDLE), NULL)); ensure_patch_validity(patch); git_patch_free(patch); } void test_patch_parse__leading_and_trailing_garbage(void) { git_patch *patch; const char *leading = "This is some leading garbage.\n" "Maybe it's email headers?\n" "\n" PATCH_ORIGINAL_TO_CHANGE_MIDDLE; const char *trailing = PATCH_ORIGINAL_TO_CHANGE_MIDDLE "\n" "This is some trailing garbage.\n" "Maybe it's an email signature?\n"; const char *both = "Here's some leading garbage\n" PATCH_ORIGINAL_TO_CHANGE_MIDDLE "And here's some trailing.\n"; cl_git_pass(git_patch_from_buffer(&patch, leading, strlen(leading), NULL)); ensure_patch_validity(patch); git_patch_free(patch); cl_git_pass(git_patch_from_buffer(&patch, trailing, strlen(trailing), NULL)); ensure_patch_validity(patch); git_patch_free(patch); cl_git_pass(git_patch_from_buffer(&patch, both, strlen(both), NULL)); ensure_patch_validity(patch); git_patch_free(patch); } void test_patch_parse__nonpatches_fail_with_notfound(void) { git_patch *patch; cl_git_fail_with(GIT_ENOTFOUND, git_patch_from_buffer(&patch, PATCH_NOT_A_PATCH, strlen(PATCH_NOT_A_PATCH), NULL)); } void test_patch_parse__invalid_patches_fails(void) { git_patch *patch; cl_git_fail_with(GIT_ERROR, git_patch_from_buffer(&patch, PATCH_CORRUPT_GIT_HEADER, strlen(PATCH_CORRUPT_GIT_HEADER), NULL)); cl_git_fail_with(GIT_ERROR, git_patch_from_buffer(&patch, PATCH_CORRUPT_MISSING_NEW_FILE, strlen(PATCH_CORRUPT_MISSING_NEW_FILE), NULL)); cl_git_fail_with(GIT_ERROR, git_patch_from_buffer(&patch, PATCH_CORRUPT_MISSING_OLD_FILE, strlen(PATCH_CORRUPT_MISSING_OLD_FILE), NULL)); cl_git_fail_with(GIT_ERROR, git_patch_from_buffer(&patch, PATCH_CORRUPT_NO_CHANGES, strlen(PATCH_CORRUPT_NO_CHANGES), NULL)); cl_git_fail_with(GIT_ERROR, git_patch_from_buffer(&patch, PATCH_CORRUPT_MISSING_HUNK_HEADER, strlen(PATCH_CORRUPT_MISSING_HUNK_HEADER), NULL)); } void test_patch_parse__no_newline_at_end_of_new_file(void) { ensure_identical_patch_inout(PATCH_APPEND_NO_NL); } void test_patch_parse__no_newline_at_end_of_old_file(void) { ensure_identical_patch_inout(PATCH_APPEND_NO_NL_IN_OLD_FILE); } void test_patch_parse__files_with_whitespaces_succeeds(void) { ensure_identical_patch_inout(PATCH_NAME_WHITESPACE); } void test_patch_parse__lifetime_of_patch_does_not_depend_on_buffer(void) { git_buf diff = GIT_BUF_INIT, rendered = GIT_BUF_INIT; git_patch *patch; cl_git_pass(git_buf_sets(&diff, PATCH_ORIGINAL_TO_CHANGE_MIDDLE)); cl_git_pass(git_patch_from_buffer(&patch, diff.ptr, diff.size, NULL)); git_buf_dispose(&diff); cl_git_pass(git_patch_to_buf(&rendered, patch)); cl_assert_equal_s(PATCH_ORIGINAL_TO_CHANGE_MIDDLE, rendered.ptr); git_buf_dispose(&rendered); cl_git_pass(git_patch_to_buf(&rendered, patch)); cl_assert_equal_s(PATCH_ORIGINAL_TO_CHANGE_MIDDLE, rendered.ptr); git_buf_dispose(&rendered); git_patch_free(patch); } void test_patch_parse__binary_file_with_missing_paths(void) { git_patch *patch; cl_git_fail(git_patch_from_buffer(&patch, PATCH_BINARY_FILE_WITH_MISSING_PATHS, strlen(PATCH_BINARY_FILE_WITH_MISSING_PATHS), NULL)); } void test_patch_parse__binary_file_with_whitespace_paths(void) { git_patch *patch; cl_git_fail(git_patch_from_buffer(&patch, PATCH_BINARY_FILE_WITH_WHITESPACE_PATHS, strlen(PATCH_BINARY_FILE_WITH_WHITESPACE_PATHS), NULL)); } void test_patch_parse__binary_file_with_empty_quoted_paths(void) { git_patch *patch; cl_git_fail(git_patch_from_buffer(&patch, PATCH_BINARY_FILE_WITH_QUOTED_EMPTY_PATHS, strlen(PATCH_BINARY_FILE_WITH_QUOTED_EMPTY_PATHS), NULL)); } void test_patch_parse__binary_file_path_with_spaces(void) { git_patch *patch; cl_git_fail(git_patch_from_buffer(&patch, PATCH_BINARY_FILE_PATH_WITH_SPACES, strlen(PATCH_BINARY_FILE_PATH_WITH_SPACES), NULL)); } void test_patch_parse__binary_file_path_without_body_paths(void) { git_patch *patch; cl_git_fail(git_patch_from_buffer(&patch, PATCH_BINARY_FILE_PATH_WITHOUT_BODY_PATHS, strlen(PATCH_BINARY_FILE_PATH_WITHOUT_BODY_PATHS), NULL)); } void test_patch_parse__binary_file_with_truncated_delta(void) { git_patch *patch; cl_git_fail(git_patch_from_buffer(&patch, PATCH_BINARY_FILE_WITH_TRUNCATED_DELTA, strlen(PATCH_BINARY_FILE_WITH_TRUNCATED_DELTA), NULL)); cl_assert_equal_s(git_error_last()->message, "truncated binary data at line 5"); } void test_patch_parse__memory_leak_on_multiple_paths(void) { git_patch *patch; cl_git_fail(git_patch_from_buffer(&patch, PATCH_MULTIPLE_OLD_PATHS, strlen(PATCH_MULTIPLE_OLD_PATHS), NULL)); } void test_patch_parse__truncated_no_newline_at_end_of_file(void) { size_t len = strlen(PATCH_APPEND_NO_NL) - strlen("at end of file\n"); const git_diff_line *line; git_patch *patch; cl_git_pass(git_patch_from_buffer(&patch, PATCH_APPEND_NO_NL, len, NULL)); cl_git_pass(git_patch_get_line_in_hunk(&line, patch, 0, 4)); cl_assert_equal_s(line->content, "\\ No newline "); git_patch_free(patch); } void test_patch_parse__line_number_overflow(void) { git_patch *patch; cl_git_fail(git_patch_from_buffer(&patch, PATCH_INTMAX_NEW_LINES, strlen(PATCH_INTMAX_NEW_LINES), NULL)); git_patch_free(patch); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/crashes.c
#include "clar_libgit2.h" void test_refs_crashes__double_free(void) { git_repository *repo; git_reference *ref, *ref2; const char *REFNAME = "refs/heads/xxx"; repo = cl_git_sandbox_init("testrepo.git"); cl_git_pass(git_reference_symbolic_create(&ref, repo, REFNAME, "refs/heads/master", 0, NULL)); cl_git_pass(git_reference_lookup(&ref2, repo, REFNAME)); cl_git_pass(git_reference_delete(ref)); git_reference_free(ref); git_reference_free(ref2); /* reference is gone from disk, so reloading it will fail */ cl_git_fail(git_reference_lookup(&ref2, repo, REFNAME)); cl_git_sandbox_cleanup(); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/isvalidname.c
#include "clar_libgit2.h" static bool is_valid_name(const char *name) { int valid; cl_git_pass(git_reference_name_is_valid(&valid, name)); return valid; } void test_refs_isvalidname__can_detect_invalid_formats(void) { cl_assert_equal_i(false, is_valid_name("refs/tags/0.17.0^{}")); cl_assert_equal_i(false, is_valid_name("TWO/LEVELS")); cl_assert_equal_i(false, is_valid_name("ONE.LEVEL")); cl_assert_equal_i(false, is_valid_name("HEAD/")); cl_assert_equal_i(false, is_valid_name("NO_TRAILING_UNDERSCORE_")); cl_assert_equal_i(false, is_valid_name("_NO_LEADING_UNDERSCORE")); cl_assert_equal_i(false, is_valid_name("HEAD/aa")); cl_assert_equal_i(false, is_valid_name("lower_case")); cl_assert_equal_i(false, is_valid_name("/stupid/name/master")); cl_assert_equal_i(false, is_valid_name("/")); cl_assert_equal_i(false, is_valid_name("//")); cl_assert_equal_i(false, is_valid_name("")); cl_assert_equal_i(false, is_valid_name("refs/heads/sub.lock/webmatrix")); } void test_refs_isvalidname__wont_hopefully_choke_on_valid_formats(void) { cl_assert_equal_i(true, is_valid_name("refs/tags/0.17.0")); cl_assert_equal_i(true, is_valid_name("refs/LEVELS")); cl_assert_equal_i(true, is_valid_name("HEAD")); cl_assert_equal_i(true, is_valid_name("ONE_LEVEL")); cl_assert_equal_i(true, is_valid_name("refs/stash")); cl_assert_equal_i(true, is_valid_name("refs/remotes/origin/bim_with_3d@11296")); cl_assert_equal_i(true, is_valid_name("refs/master{yesterday")); cl_assert_equal_i(true, is_valid_name("refs/master}yesterday")); cl_assert_equal_i(true, is_valid_name("refs/master{yesterday}")); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/create.c
#include "clar_libgit2.h" #include "repository.h" #include "git2/reflog.h" #include "reflog.h" #include "ref_helpers.h" static const char *current_master_tip = "099fabac3a9ea935598528c27f866e34089c2eff"; static const char *current_head_target = "refs/heads/master"; static git_repository *g_repo; void test_refs_create__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); p_fsync__cnt = 0; } void test_refs_create__cleanup(void) { cl_git_sandbox_cleanup(); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, 1)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION, 1)); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, 0)); } void test_refs_create__symbolic(void) { /* create a new symbolic reference */ git_reference *new_reference, *looked_up_ref, *resolved_ref; git_repository *repo2; git_oid id; const char *new_head_tracker = "ANOTHER_HEAD_TRACKER"; git_oid_fromstr(&id, current_master_tip); /* Create and write the new symbolic reference */ cl_git_pass(git_reference_symbolic_create(&new_reference, g_repo, new_head_tracker, current_head_target, 0, NULL)); /* Ensure the reference can be looked-up... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, new_head_tracker)); cl_assert(git_reference_type(looked_up_ref) & GIT_REFERENCE_SYMBOLIC); cl_assert(reference_is_packed(looked_up_ref) == 0); cl_assert_equal_s(looked_up_ref->name, new_head_tracker); /* ...peeled.. */ cl_git_pass(git_reference_resolve(&resolved_ref, looked_up_ref)); cl_assert(git_reference_type(resolved_ref) == GIT_REFERENCE_DIRECT); /* ...and that it points to the current master tip */ cl_assert_equal_oid(&id, git_reference_target(resolved_ref)); git_reference_free(looked_up_ref); git_reference_free(resolved_ref); /* Similar test with a fresh new repository */ cl_git_pass(git_repository_open(&repo2, "testrepo")); cl_git_pass(git_reference_lookup(&looked_up_ref, repo2, new_head_tracker)); cl_git_pass(git_reference_resolve(&resolved_ref, looked_up_ref)); cl_assert_equal_oid(&id, git_reference_target(resolved_ref)); git_repository_free(repo2); git_reference_free(new_reference); git_reference_free(looked_up_ref); git_reference_free(resolved_ref); } void test_refs_create__symbolic_with_arbitrary_content(void) { git_reference *new_reference, *looked_up_ref; git_repository *repo2; git_oid id; const char *new_head_tracker = "ANOTHER_HEAD_TRACKER"; const char *arbitrary_target = "ARBITRARY DATA"; git_oid_fromstr(&id, current_master_tip); /* Attempt to create symbolic ref with arbitrary data in target * fails by default */ cl_git_fail(git_reference_symbolic_create(&new_reference, g_repo, new_head_tracker, arbitrary_target, 0, NULL)); git_libgit2_opts(GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION, 0); /* With strict target validation disabled, ref creation succeeds */ cl_git_pass(git_reference_symbolic_create(&new_reference, g_repo, new_head_tracker, arbitrary_target, 0, NULL)); /* Ensure the reference can be looked-up... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, new_head_tracker)); cl_assert(git_reference_type(looked_up_ref) & GIT_REFERENCE_SYMBOLIC); cl_assert(reference_is_packed(looked_up_ref) == 0); cl_assert_equal_s(looked_up_ref->name, new_head_tracker); git_reference_free(looked_up_ref); /* Ensure the target is what we expect it to be */ cl_assert_equal_s(git_reference_symbolic_target(new_reference), arbitrary_target); /* Similar test with a fresh new repository object */ cl_git_pass(git_repository_open(&repo2, "testrepo")); /* Ensure the reference can be looked-up... */ cl_git_pass(git_reference_lookup(&looked_up_ref, repo2, new_head_tracker)); cl_assert(git_reference_type(looked_up_ref) & GIT_REFERENCE_SYMBOLIC); cl_assert(reference_is_packed(looked_up_ref) == 0); cl_assert_equal_s(looked_up_ref->name, new_head_tracker); /* Ensure the target is what we expect it to be */ cl_assert_equal_s(git_reference_symbolic_target(new_reference), arbitrary_target); git_repository_free(repo2); git_reference_free(new_reference); git_reference_free(looked_up_ref); } void test_refs_create__deep_symbolic(void) { /* create a deep symbolic reference */ git_reference *new_reference, *looked_up_ref, *resolved_ref; git_oid id; const char *new_head_tracker = "deep/rooted/tracker"; git_oid_fromstr(&id, current_master_tip); cl_git_pass(git_reference_symbolic_create(&new_reference, g_repo, new_head_tracker, current_head_target, 0, NULL)); cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, new_head_tracker)); cl_git_pass(git_reference_resolve(&resolved_ref, looked_up_ref)); cl_assert_equal_oid(&id, git_reference_target(resolved_ref)); git_reference_free(new_reference); git_reference_free(looked_up_ref); git_reference_free(resolved_ref); } void test_refs_create__oid(void) { /* create a new OID reference */ git_reference *new_reference, *looked_up_ref; git_repository *repo2; git_oid id; const char *new_head = "refs/heads/new-head"; git_oid_fromstr(&id, current_master_tip); /* Create and write the new object id reference */ cl_git_pass(git_reference_create(&new_reference, g_repo, new_head, &id, 0, NULL)); /* Ensure the reference can be looked-up... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, new_head)); cl_assert(git_reference_type(looked_up_ref) & GIT_REFERENCE_DIRECT); cl_assert(reference_is_packed(looked_up_ref) == 0); cl_assert_equal_s(looked_up_ref->name, new_head); /* ...and that it points to the current master tip */ cl_assert_equal_oid(&id, git_reference_target(looked_up_ref)); git_reference_free(looked_up_ref); /* Similar test with a fresh new repository */ cl_git_pass(git_repository_open(&repo2, "testrepo")); cl_git_pass(git_reference_lookup(&looked_up_ref, repo2, new_head)); cl_assert_equal_oid(&id, git_reference_target(looked_up_ref)); git_repository_free(repo2); git_reference_free(new_reference); git_reference_free(looked_up_ref); } /* Can by default create a reference that targets at an unknown id */ void test_refs_create__oid_unknown_succeeds_without_strict(void) { git_reference *new_reference, *looked_up_ref; git_oid id; const char *new_head = "refs/heads/new-head"; git_oid_fromstr(&id, "deadbeef3f795b2b4353bcce3a527ad0a4f7f644"); cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, 0)); /* Create and write the new object id reference */ cl_git_pass(git_reference_create(&new_reference, g_repo, new_head, &id, 0, NULL)); git_reference_free(new_reference); /* Ensure the reference can't be looked-up... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, new_head)); git_reference_free(looked_up_ref); } /* Strict object enforcement enforces valid object id */ void test_refs_create__oid_unknown_fails_by_default(void) { git_reference *new_reference, *looked_up_ref; git_oid id; const char *new_head = "refs/heads/new-head"; git_oid_fromstr(&id, "deadbeef3f795b2b4353bcce3a527ad0a4f7f644"); /* Create and write the new object id reference */ cl_git_fail(git_reference_create(&new_reference, g_repo, new_head, &id, 0, NULL)); /* Ensure the reference can't be looked-up... */ cl_git_fail(git_reference_lookup(&looked_up_ref, g_repo, new_head)); } void test_refs_create__propagate_eexists(void) { git_oid oid; /* Make sure it works for oid and for symbolic both */ cl_git_pass(git_oid_fromstr(&oid, current_master_tip)); cl_git_fail_with(GIT_EEXISTS, git_reference_create(NULL, g_repo, current_head_target, &oid, false, NULL)); cl_git_fail_with(GIT_EEXISTS, git_reference_symbolic_create(NULL, g_repo, "HEAD", current_head_target, false, NULL)); } void test_refs_create__existing_dir_propagates_edirectory(void) { git_reference *new_reference, *fail_reference; git_oid id; const char *dir_head = "refs/heads/new-dir/new-head", *fail_head = "refs/heads/new-dir"; git_oid_fromstr(&id, current_master_tip); /* Create and write the new object id reference */ cl_git_pass(git_reference_create(&new_reference, g_repo, dir_head, &id, 1, NULL)); cl_git_fail_with(GIT_EDIRECTORY, git_reference_create(&fail_reference, g_repo, fail_head, &id, false, NULL)); git_reference_free(new_reference); } static void test_invalid_name(const char *name) { git_reference *new_reference; git_oid id; git_oid_fromstr(&id, current_master_tip); cl_assert_equal_i(GIT_EINVALIDSPEC, git_reference_create( &new_reference, g_repo, name, &id, 0, NULL)); cl_assert_equal_i(GIT_EINVALIDSPEC, git_reference_symbolic_create( &new_reference, g_repo, name, current_head_target, 0, NULL)); } void test_refs_create__creating_a_reference_with_an_invalid_name_returns_EINVALIDSPEC(void) { test_invalid_name("refs/heads/inv@{id"); test_invalid_name("refs/heads/back\\slash"); test_invalid_name("refs/heads/foo "); test_invalid_name("refs/heads/foo /bar"); test_invalid_name("refs/heads/com1:bar/foo"); test_invalid_name("refs/heads/e:"); test_invalid_name("refs/heads/c:/foo"); test_invalid_name("refs/heads/foo."); } static void test_win32_name(const char *name) { git_reference *new_reference = NULL; git_oid id; int ret; git_oid_fromstr(&id, current_master_tip); ret = git_reference_create(&new_reference, g_repo, name, &id, 0, NULL); #ifdef GIT_WIN32 cl_assert_equal_i(GIT_EINVALIDSPEC, ret); #else cl_git_pass(ret); #endif git_reference_free(new_reference); } void test_refs_create__creating_a_loose_ref_with_invalid_windows_name(void) { test_win32_name("refs/heads/foo./bar"); test_win32_name("refs/heads/aux"); test_win32_name("refs/heads/aux.foo/bar"); test_win32_name("refs/heads/com1"); } /* Creating a loose ref involves fsync'ing the reference, the * reflog and (on non-Windows) the containing directories. * Creating a packed ref involves fsync'ing the packed ref file * and (on non-Windows) the containing directory. */ #ifdef GIT_WIN32 static int expected_fsyncs_create = 2, expected_fsyncs_compress = 1; #else static int expected_fsyncs_create = 4, expected_fsyncs_compress = 2; #endif static void count_fsyncs(size_t *create_count, size_t *compress_count) { git_reference *ref = NULL; git_refdb *refdb; git_oid id; p_fsync__cnt = 0; git_oid_fromstr(&id, current_master_tip); cl_git_pass(git_reference_create(&ref, g_repo, "refs/heads/fsync_test", &id, 0, "log message")); git_reference_free(ref); *create_count = p_fsync__cnt; p_fsync__cnt = 0; cl_git_pass(git_repository_refdb(&refdb, g_repo)); cl_git_pass(git_refdb_compress(refdb)); git_refdb_free(refdb); *compress_count = p_fsync__cnt; p_fsync__cnt = 0; } void test_refs_create__does_not_fsync_by_default(void) { size_t create_count, compress_count; count_fsyncs(&create_count, &compress_count); cl_assert_equal_i(0, create_count); cl_assert_equal_i(0, compress_count); } void test_refs_create__fsyncs_when_global_opt_set(void) { size_t create_count, compress_count; cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, 1)); count_fsyncs(&create_count, &compress_count); cl_assert_equal_i(expected_fsyncs_create, create_count); cl_assert_equal_i(expected_fsyncs_compress, compress_count); } void test_refs_create__fsyncs_when_repo_config_set(void) { size_t create_count, compress_count; cl_repo_set_bool(g_repo, "core.fsyncObjectFiles", true); count_fsyncs(&create_count, &compress_count); cl_assert_equal_i(expected_fsyncs_create, create_count); cl_assert_equal_i(expected_fsyncs_compress, compress_count); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/transactions.c
#include "clar_libgit2.h" #include "git2/transaction.h" static git_repository *g_repo; static git_transaction *g_tx; void test_refs_transactions__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); cl_git_pass(git_transaction_new(&g_tx, g_repo)); } void test_refs_transactions__cleanup(void) { git_transaction_free(g_tx); cl_git_sandbox_cleanup(); } void test_refs_transactions__single_ref_oid(void) { git_reference *ref; git_oid id; git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); cl_git_pass(git_transaction_lock_ref(g_tx, "refs/heads/master")); cl_git_pass(git_transaction_set_target(g_tx, "refs/heads/master", &id, NULL, NULL)); cl_git_pass(git_transaction_commit(g_tx)); cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/heads/master")); cl_assert(!git_oid_cmp(&id, git_reference_target(ref))); git_reference_free(ref); } void test_refs_transactions__single_ref_symbolic(void) { git_reference *ref; cl_git_pass(git_transaction_lock_ref(g_tx, "HEAD")); cl_git_pass(git_transaction_set_symbolic_target(g_tx, "HEAD", "refs/heads/foo", NULL, NULL)); cl_git_pass(git_transaction_commit(g_tx)); cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD")); cl_assert_equal_s("refs/heads/foo", git_reference_symbolic_target(ref)); git_reference_free(ref); } void test_refs_transactions__single_ref_mix_types(void) { git_reference *ref; git_oid id; git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); cl_git_pass(git_transaction_lock_ref(g_tx, "refs/heads/master")); cl_git_pass(git_transaction_lock_ref(g_tx, "HEAD")); cl_git_pass(git_transaction_set_symbolic_target(g_tx, "refs/heads/master", "refs/heads/foo", NULL, NULL)); cl_git_pass(git_transaction_set_target(g_tx, "HEAD", &id, NULL, NULL)); cl_git_pass(git_transaction_commit(g_tx)); cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/heads/master")); cl_assert_equal_s("refs/heads/foo", git_reference_symbolic_target(ref)); git_reference_free(ref); cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD")); cl_assert(!git_oid_cmp(&id, git_reference_target(ref))); git_reference_free(ref); } void test_refs_transactions__single_ref_delete(void) { git_reference *ref; cl_git_pass(git_transaction_lock_ref(g_tx, "refs/heads/master")); cl_git_pass(git_transaction_remove(g_tx, "refs/heads/master")); cl_git_pass(git_transaction_commit(g_tx)); cl_git_fail_with(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo, "refs/heads/master")); } void test_refs_transactions__single_create(void) { git_reference *ref; const char *name = "refs/heads/new-branch"; git_oid id; cl_git_fail_with(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo, name)); cl_git_pass(git_transaction_lock_ref(g_tx, name)); git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); cl_git_pass(git_transaction_set_target(g_tx, name, &id, NULL, NULL)); cl_git_pass(git_transaction_commit(g_tx)); cl_git_pass(git_reference_lookup(&ref, g_repo, name)); cl_assert(!git_oid_cmp(&id, git_reference_target(ref))); git_reference_free(ref); } void test_refs_transactions__unlocked_set(void) { git_oid id; cl_git_pass(git_transaction_lock_ref(g_tx, "refs/heads/master")); git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); cl_git_fail_with(GIT_ENOTFOUND, git_transaction_set_target(g_tx, "refs/heads/foo", &id, NULL, NULL)); cl_git_pass(git_transaction_commit(g_tx)); } void test_refs_transactions__error_on_locking_locked_ref(void) { git_oid id; git_transaction *g_tx_with_lock; git_repository *g_repo_with_locking_tx; const char *g_repo_path = git_repository_path(g_repo); /* prepare a separate transaction in another instance of testrepo and lock master */ cl_git_pass(git_repository_open(&g_repo_with_locking_tx, g_repo_path)); cl_git_pass(git_transaction_new(&g_tx_with_lock, g_repo_with_locking_tx)); cl_git_pass(git_transaction_lock_ref(g_tx_with_lock, "refs/heads/master")); /* lock reference for set_target */ cl_git_pass(git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750")); cl_git_fail_with(GIT_ELOCKED, git_transaction_lock_ref(g_tx, "refs/heads/master")); cl_git_fail_with(GIT_ENOTFOUND, git_transaction_set_target(g_tx, "refs/heads/master", &id, NULL, NULL)); git_transaction_free(g_tx_with_lock); git_repository_free(g_repo_with_locking_tx); } void test_refs_transactions__commit_unlocks_unmodified_ref(void) { git_transaction *second_tx; cl_git_pass(git_transaction_new(&second_tx, g_repo)); cl_git_pass(git_transaction_lock_ref(second_tx, "refs/heads/master")); cl_git_pass(git_transaction_commit(second_tx)); /* a transaction must now be able to get the lock */ cl_git_pass(git_transaction_lock_ref(g_tx, "refs/heads/master")); git_transaction_free(second_tx); } void test_refs_transactions__free_unlocks_unmodified_ref(void) { git_transaction *second_tx; cl_git_pass(git_transaction_new(&second_tx, g_repo)); cl_git_pass(git_transaction_lock_ref(second_tx, "refs/heads/master")); git_transaction_free(second_tx); /* a transaction must now be able to get the lock */ cl_git_pass(git_transaction_lock_ref(g_tx, "refs/heads/master")); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/setter.c
#include "clar_libgit2.h" #include "repository.h" #include "git2/reflog.h" #include "reflog.h" #include "git2/refs.h" static const char *ref_name = "refs/heads/other"; static const char *ref_master_name = "refs/heads/master"; static const char *ref_test_name = "refs/heads/test"; static git_repository *g_repo; void test_refs_setter__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); } void test_refs_setter__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_setter__update_direct(void) { git_reference *ref, *test_ref, *new_ref; git_oid id; cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) == GIT_REFERENCE_DIRECT); git_oid_cpy(&id, git_reference_target(ref)); git_reference_free(ref); cl_git_pass(git_reference_lookup(&test_ref, g_repo, ref_test_name)); cl_assert(git_reference_type(test_ref) == GIT_REFERENCE_DIRECT); cl_git_pass(git_reference_set_target(&new_ref, test_ref, &id, NULL)); git_reference_free(test_ref); git_reference_free(new_ref); cl_git_pass(git_reference_lookup(&test_ref, g_repo, ref_test_name)); cl_assert(git_reference_type(test_ref) == GIT_REFERENCE_DIRECT); cl_assert_equal_oid(&id, git_reference_target(test_ref)); git_reference_free(test_ref); } void test_refs_setter__update_symbolic(void) { git_reference *head, *new_head; cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD")); cl_assert(git_reference_type(head) == GIT_REFERENCE_SYMBOLIC); cl_assert(strcmp(git_reference_symbolic_target(head), ref_master_name) == 0); cl_git_pass(git_reference_symbolic_set_target(&new_head, head, ref_test_name, NULL)); git_reference_free(new_head); git_reference_free(head); cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD")); cl_assert(git_reference_type(head) == GIT_REFERENCE_SYMBOLIC); cl_assert(strcmp(git_reference_symbolic_target(head), ref_test_name) == 0); git_reference_free(head); } void test_refs_setter__cant_update_direct_with_symbolic(void) { /* Overwrite an existing object id reference with a symbolic one */ git_reference *ref, *new; git_oid id; cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) == GIT_REFERENCE_DIRECT); git_oid_cpy(&id, git_reference_target(ref)); cl_git_fail(git_reference_symbolic_set_target(&new, ref, ref_name, NULL)); git_reference_free(ref); } void test_refs_setter__cant_update_symbolic_with_direct(void) { /* Overwrite an existing symbolic reference with an object id one */ git_reference *ref, *new; git_oid id; cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) == GIT_REFERENCE_DIRECT); git_oid_cpy(&id, git_reference_target(ref)); git_reference_free(ref); /* Create the symbolic ref */ cl_git_pass(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 0, NULL)); /* Can't set an OID on a direct ref */ cl_git_fail(git_reference_set_target(&new, ref, &id, NULL)); git_reference_free(ref); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/races.c
#include "clar_libgit2.h" #include "repository.h" #include "git2/reflog.h" #include "reflog.h" #include "ref_helpers.h" static const char *commit_id = "099fabac3a9ea935598528c27f866e34089c2eff"; static const char *refname = "refs/heads/master"; static const char *other_refname = "refs/heads/foo"; static const char *other_commit_id = "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"; static git_repository *g_repo; void test_refs_races__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); } void test_refs_races__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_races__create_matching_zero_old(void) { git_reference *ref; git_oid id, zero_id; git_oid_fromstr(&id, commit_id); git_oid_fromstr(&zero_id, "0000000000000000000000000000000000000000"); cl_git_fail(git_reference_create_matching(&ref, g_repo, refname, &id, 1, &zero_id, NULL)); git_reference_free(ref); cl_git_pass(git_reference_create_matching(&ref, g_repo, other_refname, &id, 1, &zero_id, NULL)); git_reference_free(ref); cl_git_fail(git_reference_create_matching(&ref, g_repo, other_refname, &id, 1, &zero_id, NULL)); git_reference_free(ref); } void test_refs_races__create_matching(void) { git_reference *ref, *ref2, *ref3; git_oid id, other_id; git_oid_fromstr(&id, commit_id); git_oid_fromstr(&other_id, other_commit_id); cl_git_fail_with(GIT_EMODIFIED, git_reference_create_matching(&ref, g_repo, refname, &other_id, 1, &other_id, NULL)); cl_git_pass(git_reference_lookup(&ref, g_repo, refname)); cl_git_pass(git_reference_create_matching(&ref2, g_repo, refname, &other_id, 1, &id, NULL)); cl_git_fail_with(GIT_EMODIFIED, git_reference_set_target(&ref3, ref, &other_id, NULL)); git_reference_free(ref); git_reference_free(ref2); git_reference_free(ref3); } void test_refs_races__symbolic_create_matching(void) { git_reference *ref, *ref2, *ref3; git_oid id, other_id; git_oid_fromstr(&id, commit_id); git_oid_fromstr(&other_id, other_commit_id); cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_create_matching(&ref, g_repo, "HEAD", other_refname, 1, other_refname, NULL)); cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD")); cl_git_pass(git_reference_symbolic_create_matching(&ref2, g_repo, "HEAD", other_refname, 1, NULL, refname)); cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_set_target(&ref3, ref, other_refname, NULL)); git_reference_free(ref); git_reference_free(ref2); git_reference_free(ref3); } void test_refs_races__delete(void) { git_reference *ref, *ref2; git_oid id, other_id; git_oid_fromstr(&id, commit_id); git_oid_fromstr(&other_id, other_commit_id); /* We can delete a value that matches */ cl_git_pass(git_reference_lookup(&ref, g_repo, refname)); cl_git_pass(git_reference_delete(ref)); git_reference_free(ref); /* We cannot delete a symbolic value that doesn't match */ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref")); cl_git_pass(git_reference_symbolic_create_matching(&ref2, g_repo, "refs/symref", other_refname, 1, NULL, refname)); cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref)); git_reference_free(ref); git_reference_free(ref2); cl_git_pass(git_reference_create(&ref, g_repo, refname, &id, 1, NULL)); git_reference_free(ref); /* We cannot delete an oid value that doesn't match */ cl_git_pass(git_reference_lookup(&ref, g_repo, refname)); cl_git_pass(git_reference_create_matching(&ref2, g_repo, refname, &other_id, 1, &id, NULL)); cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref)); git_reference_free(ref); git_reference_free(ref2); } void test_refs_races__switch_oid_to_symbolic(void) { git_reference *ref, *ref2, *ref3; git_oid id, other_id; git_oid_fromstr(&id, commit_id); git_oid_fromstr(&other_id, other_commit_id); /* Removing a direct ref when it's currently symbolic should fail */ cl_git_pass(git_reference_lookup(&ref, g_repo, refname)); cl_git_pass(git_reference_symbolic_create(&ref2, g_repo, refname, other_refname, 1, NULL)); cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref)); git_reference_free(ref); git_reference_free(ref2); cl_git_pass(git_reference_create(&ref, g_repo, refname, &id, 1, NULL)); git_reference_free(ref); /* Updating a direct ref when it's currently symbolic should fail */ cl_git_pass(git_reference_lookup(&ref, g_repo, refname)); cl_git_pass(git_reference_symbolic_create(&ref2, g_repo, refname, other_refname, 1, NULL)); cl_git_fail_with(GIT_EMODIFIED, git_reference_set_target(&ref3, ref, &other_id, NULL)); git_reference_free(ref); git_reference_free(ref2); git_reference_free(ref3); } void test_refs_races__switch_symbolic_to_oid(void) { git_reference *ref, *ref2, *ref3; git_oid id, other_id; git_oid_fromstr(&id, commit_id); git_oid_fromstr(&other_id, other_commit_id); /* Removing a symbolic ref when it's currently direct should fail */ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref")); cl_git_pass(git_reference_create(&ref2, g_repo, "refs/symref", &id, 1, NULL)); cl_git_fail_with(GIT_EMODIFIED, git_reference_delete(ref)); git_reference_free(ref); git_reference_free(ref2); cl_git_pass(git_reference_symbolic_create(&ref, g_repo, "refs/symref", refname, 1, NULL)); git_reference_free(ref); /* Updating a symbolic ref when it's currently direct should fail */ cl_git_pass(git_reference_lookup(&ref, g_repo, "refs/symref")); cl_git_pass(git_reference_create(&ref2, g_repo, "refs/symref", &id, 1, NULL)); cl_git_fail_with(GIT_EMODIFIED, git_reference_symbolic_set_target(&ref3, ref, other_refname, NULL)); git_reference_free(ref); git_reference_free(ref2); git_reference_free(ref3); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/overwrite.c
#include "clar_libgit2.h" #include "repository.h" #include "git2/reflog.h" #include "reflog.h" static const char *ref_name = "refs/heads/other"; static const char *ref_master_name = "refs/heads/master"; static const char *ref_branch_name = "refs/heads/branch"; static const char *ref_test_name = "refs/heads/test"; static git_repository *g_repo; void test_refs_overwrite__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); } void test_refs_overwrite__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_overwrite__symbolic(void) { /* Overwrite an existing symbolic reference */ git_reference *ref, *branch_ref; /* The target needds to exist and we need to check the name has changed */ cl_git_pass(git_reference_symbolic_create(&branch_ref, g_repo, ref_branch_name, ref_master_name, 0, NULL)); cl_git_pass(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_branch_name, 0, NULL)); git_reference_free(ref); /* Ensure it points to the right place*/ cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_SYMBOLIC); cl_assert_equal_s(git_reference_symbolic_target(ref), ref_branch_name); git_reference_free(ref); /* Ensure we can't create it unless we force it to */ cl_git_fail(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 0, NULL)); cl_git_pass(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 1, NULL)); git_reference_free(ref); /* Ensure it points to the right place */ cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_SYMBOLIC); cl_assert_equal_s(git_reference_symbolic_target(ref), ref_master_name); git_reference_free(ref); git_reference_free(branch_ref); } void test_refs_overwrite__object_id(void) { /* Overwrite an existing object id reference */ git_reference *ref; git_oid id; cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_DIRECT); git_oid_cpy(&id, git_reference_target(ref)); git_reference_free(ref); /* Create it */ cl_git_pass(git_reference_create(&ref, g_repo, ref_name, &id, 0, NULL)); git_reference_free(ref); cl_git_pass(git_reference_lookup(&ref, g_repo, ref_test_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_DIRECT); git_oid_cpy(&id, git_reference_target(ref)); git_reference_free(ref); /* Ensure we can't overwrite unless we force it */ cl_git_fail(git_reference_create(&ref, g_repo, ref_name, &id, 0, NULL)); cl_git_pass(git_reference_create(&ref, g_repo, ref_name, &id, 1, NULL)); git_reference_free(ref); /* Ensure it has been overwritten */ cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name)); cl_assert_equal_oid(&id, git_reference_target(ref)); git_reference_free(ref); } void test_refs_overwrite__object_id_with_symbolic(void) { /* Overwrite an existing object id reference with a symbolic one */ git_reference *ref; git_oid id; cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_DIRECT); git_oid_cpy(&id, git_reference_target(ref)); git_reference_free(ref); cl_git_pass(git_reference_create(&ref, g_repo, ref_name, &id, 0, NULL)); git_reference_free(ref); cl_git_fail(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 0, NULL)); cl_git_pass(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 1, NULL)); git_reference_free(ref); /* Ensure it points to the right place */ cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_SYMBOLIC); cl_assert_equal_s(git_reference_symbolic_target(ref), ref_master_name); git_reference_free(ref); } void test_refs_overwrite__symbolic_with_object_id(void) { /* Overwrite an existing symbolic reference with an object id one */ git_reference *ref; git_oid id; cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_DIRECT); git_oid_cpy(&id, git_reference_target(ref)); git_reference_free(ref); /* Create the symbolic ref */ cl_git_pass(git_reference_symbolic_create(&ref, g_repo, ref_name, ref_master_name, 0, NULL)); git_reference_free(ref); /* It shouldn't overwrite unless we tell it to */ cl_git_fail(git_reference_create(&ref, g_repo, ref_name, &id, 0, NULL)); cl_git_pass(git_reference_create(&ref, g_repo, ref_name, &id, 1, NULL)); git_reference_free(ref); /* Ensure it points to the right place */ cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_DIRECT); cl_assert_equal_oid(&id, git_reference_target(ref)); git_reference_free(ref); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/unicode.c
#include "clar_libgit2.h" static git_repository *repo; void test_refs_unicode__initialize(void) { repo = cl_git_sandbox_init("testrepo.git"); } void test_refs_unicode__cleanup(void) { cl_git_sandbox_cleanup(); repo = NULL; } void test_refs_unicode__create_and_lookup(void) { git_reference *ref0, *ref1, *ref2; git_repository *repo2; const char *REFNAME = "refs/heads/" "\303\205" "ngstr" "\303\266" "m"; const char *master = "refs/heads/master"; /* Create the reference */ cl_git_pass(git_reference_lookup(&ref0, repo, master)); cl_git_pass(git_reference_create( &ref1, repo, REFNAME, git_reference_target(ref0), 0, NULL)); cl_assert_equal_s(REFNAME, git_reference_name(ref1)); git_reference_free(ref0); /* Lookup the reference in a different instance of the repository */ cl_git_pass(git_repository_open(&repo2, "testrepo.git")); cl_git_pass(git_reference_lookup(&ref2, repo2, REFNAME)); cl_assert_equal_oid(git_reference_target(ref1), git_reference_target(ref2)); cl_assert_equal_s(REFNAME, git_reference_name(ref2)); git_reference_free(ref2); #if GIT_USE_ICONV /* Lookup reference by decomposed unicode name */ #define REFNAME_DECOMPOSED "refs/heads/" "A" "\314\212" "ngstro" "\314\210" "m" cl_git_pass(git_reference_lookup(&ref2, repo2, REFNAME_DECOMPOSED)); cl_assert_equal_oid(git_reference_target(ref1), git_reference_target(ref2)); cl_assert_equal_s(REFNAME, git_reference_name(ref2)); git_reference_free(ref2); #endif /* Cleanup */ git_reference_free(ref1); git_repository_free(repo2); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/namespaces.c
#include "clar_libgit2.h" #include "repository.h" static git_repository *g_repo; void test_refs_namespaces__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); } void test_refs_namespaces__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_namespaces__get_and_set(void) { cl_assert_equal_s(NULL, git_repository_get_namespace(g_repo)); cl_git_pass(git_repository_set_namespace(g_repo, "namespace")); cl_assert_equal_s("namespace", git_repository_get_namespace(g_repo)); cl_git_pass(git_repository_set_namespace(g_repo, NULL)); cl_assert_equal_s(NULL, git_repository_get_namespace(g_repo)); } void test_refs_namespaces__namespace_doesnt_show_normal_refs(void) { static git_strarray ref_list; cl_git_pass(git_repository_set_namespace(g_repo, "namespace")); cl_git_pass(git_reference_list(&ref_list, g_repo)); cl_assert_equal_i(0, ref_list.count); git_strarray_dispose(&ref_list); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/normalize.c
#include "clar_libgit2.h" #include "repository.h" #include "git2/reflog.h" #include "reflog.h" /* Helpers */ static void ensure_refname_normalized( unsigned int flags, const char *input_refname, const char *expected_refname) { char buffer_out[GIT_REFNAME_MAX]; cl_git_pass(git_reference_normalize_name(buffer_out, sizeof(buffer_out), input_refname, flags)); cl_assert_equal_s(expected_refname, buffer_out); } static void ensure_refname_invalid(unsigned int flags, const char *input_refname) { char buffer_out[GIT_REFNAME_MAX]; cl_assert_equal_i( GIT_EINVALIDSPEC, git_reference_normalize_name(buffer_out, sizeof(buffer_out), input_refname, flags)); } void test_refs_normalize__can_normalize_a_direct_reference_name(void) { ensure_refname_normalized( GIT_REFERENCE_FORMAT_NORMAL, "refs/dummy/a", "refs/dummy/a"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_NORMAL, "refs/stash", "refs/stash"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_NORMAL, "refs/tags/a", "refs/tags/a"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/a/b", "refs/heads/a/b"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/a./b", "refs/heads/a./b"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/v@ation", "refs/heads/v@ation"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_NORMAL, "refs///heads///a", "refs/heads/a"); } void test_refs_normalize__cannot_normalize_any_direct_reference_name(void) { ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "a"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "/a"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "//a"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, ""); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "/refs/heads/a/"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/a/"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/a."); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/a.lock"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/foo?bar"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads\foo"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/v@ation", "refs/heads/v@ation"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_NORMAL, "refs///heads///a", "refs/heads/a"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/.a/b"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/foo/../bar"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/foo..bar"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/./foo"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "refs/heads/v@{ation"); } void test_refs_normalize__symbolic(void) { ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, ""); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "heads\foo"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "/"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "///"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "ALL_CAPS_AND_UNDERSCORES", "ALL_CAPS_AND_UNDERSCORES"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/MixedCasing", "refs/MixedCasing"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs///heads///a", "refs/heads/a"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "HEAD", "HEAD"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "MERGE_HEAD", "MERGE_HEAD"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "FETCH_HEAD", "FETCH_HEAD"); } /* Ported from JGit, BSD licence. * See https://github.com/spearce/JGit/commit/e4bf8f6957bbb29362575d641d1e77a02d906739 * * Copyright (C) 2009, Google Inc. * * All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * - Neither the name of the Git Development Community nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ void test_refs_normalize__jgit_suite(void) { /* tests borrowed from JGit */ /* EmptyString */ ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, ""); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "/"); /* MustHaveTwoComponents */ ensure_refname_invalid( GIT_REFERENCE_FORMAT_NORMAL, "master"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_NORMAL, "heads/master", "heads/master"); /* ValidHead */ ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master", "refs/heads/master"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/pu", "refs/heads/pu"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/z", "refs/heads/z"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/FoO", "refs/heads/FoO"); /* ValidTag */ ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/tags/v1.0", "refs/tags/v1.0"); /* NoLockSuffix */ ensure_refname_invalid(GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master.lock"); /* NoDirectorySuffix */ ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master/"); /* NoSpace */ ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/i haz space"); /* NoAsciiControlCharacters */ { char c; char buffer[GIT_REFNAME_MAX]; for (c = '\1'; c < ' '; c++) { p_snprintf(buffer, sizeof(buffer), "refs/heads/mast%cer", c); ensure_refname_invalid(GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, buffer); } } /* NoBareDot */ ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/."); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/.."); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/./master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/../master"); /* NoLeadingOrTrailingDot */ ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "."); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/.bar"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/..bar"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/bar."); /* ContainsDot */ ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/m.a.s.t.e.r", "refs/heads/m.a.s.t.e.r"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master..pu"); /* NoMagicRefCharacters */ ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master^"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/^master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "^refs/heads/master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master~"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/~master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "~refs/heads/master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master:"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/:master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, ":refs/heads/master"); /* ShellGlob */ ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master?"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/?master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "?refs/heads/master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master["); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/[master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "[refs/heads/master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master*"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/*master"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "*refs/heads/master"); /* ValidSpecialCharacters */ ensure_refname_normalized (GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/!", "refs/heads/!"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/\"", "refs/heads/\""); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/#", "refs/heads/#"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/$", "refs/heads/$"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/%", "refs/heads/%"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/&", "refs/heads/&"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/'", "refs/heads/'"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/(", "refs/heads/("); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/)", "refs/heads/)"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/+", "refs/heads/+"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/,", "refs/heads/,"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/-", "refs/heads/-"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/;", "refs/heads/;"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/<", "refs/heads/<"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/=", "refs/heads/="); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/>", "refs/heads/>"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/@", "refs/heads/@"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/]", "refs/heads/]"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/_", "refs/heads/_"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/`", "refs/heads/`"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/{", "refs/heads/{"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/|", "refs/heads/|"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/}", "refs/heads/}"); /* * This is valid on UNIX, but not on Windows * hence we make in invalid due to non-portability */ ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/\\"); /* UnicodeNames */ /* * Currently this fails. * ensure_refname_normalized(GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/\u00e5ngstr\u00f6m", "refs/heads/\u00e5ngstr\u00f6m"); */ /* RefLogQueryIsValidRef */ ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master@{1}"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL, "refs/heads/master@{1.hour.ago}"); } void test_refs_normalize__buffer_has_to_be_big_enough_to_hold_the_normalized_version(void) { char buffer_out[21]; cl_git_pass(git_reference_normalize_name( buffer_out, 21, "refs//heads///long///name", GIT_REFERENCE_FORMAT_NORMAL)); cl_git_fail(git_reference_normalize_name( buffer_out, 20, "refs//heads///long///name", GIT_REFERENCE_FORMAT_NORMAL)); } #define ONE_LEVEL_AND_REFSPEC \ GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL \ | GIT_REFERENCE_FORMAT_REFSPEC_PATTERN void test_refs_normalize__refspec_pattern(void) { ensure_refname_normalized( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "heads/*foo/bar", "heads/*foo/bar"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "heads/foo*/bar", "heads/foo*/bar"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "heads/f*o/bar", "heads/f*o/bar"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "foo"); ensure_refname_normalized( ONE_LEVEL_AND_REFSPEC, "FOO", "FOO"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "foo/bar", "foo/bar"); ensure_refname_normalized( ONE_LEVEL_AND_REFSPEC, "foo/bar", "foo/bar"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "*/foo", "*/foo"); ensure_refname_normalized( ONE_LEVEL_AND_REFSPEC, "*/foo", "*/foo"); ensure_refname_normalized( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "foo/*/bar", "foo/*/bar"); ensure_refname_normalized( ONE_LEVEL_AND_REFSPEC, "foo/*/bar", "foo/*/bar"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "*"); ensure_refname_normalized( ONE_LEVEL_AND_REFSPEC, "*", "*"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "foo/*/*"); ensure_refname_invalid( ONE_LEVEL_AND_REFSPEC, "foo/*/*"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "*/foo/*"); ensure_refname_invalid( ONE_LEVEL_AND_REFSPEC, "*/foo/*"); ensure_refname_invalid( GIT_REFERENCE_FORMAT_REFSPEC_PATTERN, "*/*/foo"); ensure_refname_invalid( ONE_LEVEL_AND_REFSPEC, "*/*/foo"); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/pack.c
#include "clar_libgit2.h" #include "futils.h" #include "git2/reflog.h" #include "git2/refdb.h" #include "reflog.h" #include "refs.h" #include "ref_helpers.h" static const char *loose_tag_ref_name = "refs/tags/e90810b"; static git_repository *g_repo; void test_refs_pack__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); } void test_refs_pack__cleanup(void) { cl_git_sandbox_cleanup(); } static void packall(void) { git_refdb *refdb; cl_git_pass(git_repository_refdb(&refdb, g_repo)); cl_git_pass(git_refdb_compress(refdb)); git_refdb_free(refdb); } void test_refs_pack__empty(void) { /* create a packfile for an empty folder */ git_buf temp_path = GIT_BUF_INIT; cl_git_pass(git_buf_join_n(&temp_path, '/', 3, git_repository_path(g_repo), GIT_REFS_HEADS_DIR, "empty_dir")); cl_git_pass(git_futils_mkdir_r(temp_path.ptr, GIT_REFS_DIR_MODE)); git_buf_dispose(&temp_path); packall(); } void test_refs_pack__loose(void) { /* create a packfile from all the loose refs in a repo */ git_reference *reference; git_buf temp_path = GIT_BUF_INIT; /* Ensure a known loose ref can be looked up */ cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name)); cl_assert(reference_is_packed(reference) == 0); cl_assert_equal_s(reference->name, loose_tag_ref_name); git_reference_free(reference); /* * We are now trying to pack also a loose reference * called `points_to_blob`, to make sure we can properly * pack weak tags */ packall(); /* Ensure the packed-refs file exists */ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), GIT_PACKEDREFS_FILE)); cl_assert(git_path_exists(temp_path.ptr)); /* Ensure the known ref can still be looked up but is now packed */ cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name)); cl_assert(reference_is_packed(reference)); cl_assert_equal_s(reference->name, loose_tag_ref_name); /* Ensure the known ref has been removed from the loose folder structure */ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), loose_tag_ref_name)); cl_assert(!git_path_exists(temp_path.ptr)); git_reference_free(reference); git_buf_dispose(&temp_path); } void test_refs_pack__symbolic(void) { /* create a packfile from loose refs skipping symbolic refs */ int i; git_oid head; git_reference *ref; char name[128]; cl_git_pass(git_reference_name_to_id(&head, g_repo, "HEAD")); /* make a bunch of references */ for (i = 0; i < 100; ++i) { p_snprintf(name, sizeof(name), "refs/heads/symbolic-%03d", i); cl_git_pass(git_reference_symbolic_create( &ref, g_repo, name, "refs/heads/master", 0, NULL)); git_reference_free(ref); p_snprintf(name, sizeof(name), "refs/heads/direct-%03d", i); cl_git_pass(git_reference_create(&ref, g_repo, name, &head, 0, NULL)); git_reference_free(ref); } packall(); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/read.c
#include "clar_libgit2.h" #include "repository.h" #include "git2/reflog.h" #include "reflog.h" #include "ref_helpers.h" static const char *loose_tag_ref_name = "refs/tags/e90810b"; static const char *non_existing_tag_ref_name = "refs/tags/i-do-not-exist"; static const char *head_tracker_sym_ref_name = "HEAD_TRACKER"; static const char *current_head_target = "refs/heads/master"; static const char *current_master_tip = "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"; static const char *packed_head_name = "refs/heads/packed"; static const char *packed_test_head_name = "refs/heads/packed-test"; static git_repository *g_repo; void test_refs_read__initialize(void) { cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git"))); } void test_refs_read__cleanup(void) { git_repository_free(g_repo); g_repo = NULL; } void test_refs_read__loose_tag(void) { /* lookup a loose tag reference */ git_reference *reference; git_object *object; git_buf ref_name_from_tag_name = GIT_BUF_INIT; cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name)); cl_assert(git_reference_type(reference) & GIT_REFERENCE_DIRECT); cl_assert(reference_is_packed(reference) == 0); cl_assert_equal_s(reference->name, loose_tag_ref_name); cl_git_pass(git_object_lookup(&object, g_repo, git_reference_target(reference), GIT_OBJECT_ANY)); cl_assert(object != NULL); cl_assert(git_object_type(object) == GIT_OBJECT_TAG); /* Ensure the name of the tag matches the name of the reference */ cl_git_pass(git_buf_joinpath(&ref_name_from_tag_name, GIT_REFS_TAGS_DIR, git_tag_name((git_tag *)object))); cl_assert_equal_s(ref_name_from_tag_name.ptr, loose_tag_ref_name); git_buf_dispose(&ref_name_from_tag_name); git_object_free(object); git_reference_free(reference); } void test_refs_read__nonexisting_tag(void) { /* lookup a loose tag reference that doesn't exist */ git_reference *reference; cl_git_fail(git_reference_lookup(&reference, g_repo, non_existing_tag_ref_name)); git_reference_free(reference); } void test_refs_read__symbolic(void) { /* lookup a symbolic reference */ git_reference *reference, *resolved_ref; git_object *object; git_oid id; cl_git_pass(git_reference_lookup(&reference, g_repo, GIT_HEAD_FILE)); cl_assert(git_reference_type(reference) & GIT_REFERENCE_SYMBOLIC); cl_assert(reference_is_packed(reference) == 0); cl_assert_equal_s(reference->name, GIT_HEAD_FILE); cl_git_pass(git_reference_resolve(&resolved_ref, reference)); cl_assert(git_reference_type(resolved_ref) == GIT_REFERENCE_DIRECT); cl_git_pass(git_object_lookup(&object, g_repo, git_reference_target(resolved_ref), GIT_OBJECT_ANY)); cl_assert(object != NULL); cl_assert(git_object_type(object) == GIT_OBJECT_COMMIT); git_oid_fromstr(&id, current_master_tip); cl_assert_equal_oid(&id, git_object_id(object)); git_object_free(object); git_reference_free(reference); git_reference_free(resolved_ref); } void test_refs_read__nested_symbolic(void) { /* lookup a nested symbolic reference */ git_reference *reference, *resolved_ref; git_object *object; git_oid id; cl_git_pass(git_reference_lookup(&reference, g_repo, head_tracker_sym_ref_name)); cl_assert(git_reference_type(reference) & GIT_REFERENCE_SYMBOLIC); cl_assert(reference_is_packed(reference) == 0); cl_assert_equal_s(reference->name, head_tracker_sym_ref_name); cl_git_pass(git_reference_resolve(&resolved_ref, reference)); cl_assert(git_reference_type(resolved_ref) == GIT_REFERENCE_DIRECT); cl_git_pass(git_object_lookup(&object, g_repo, git_reference_target(resolved_ref), GIT_OBJECT_ANY)); cl_assert(object != NULL); cl_assert(git_object_type(object) == GIT_OBJECT_COMMIT); git_oid_fromstr(&id, current_master_tip); cl_assert_equal_oid(&id, git_object_id(object)); git_object_free(object); git_reference_free(reference); git_reference_free(resolved_ref); } void test_refs_read__head_then_master(void) { /* lookup the HEAD and resolve the master branch */ git_reference *reference, *resolved_ref, *comp_base_ref; cl_git_pass(git_reference_lookup(&reference, g_repo, head_tracker_sym_ref_name)); cl_git_pass(git_reference_resolve(&comp_base_ref, reference)); git_reference_free(reference); cl_git_pass(git_reference_lookup(&reference, g_repo, GIT_HEAD_FILE)); cl_git_pass(git_reference_resolve(&resolved_ref, reference)); cl_assert_equal_oid(git_reference_target(comp_base_ref), git_reference_target(resolved_ref)); git_reference_free(reference); git_reference_free(resolved_ref); cl_git_pass(git_reference_lookup(&reference, g_repo, current_head_target)); cl_git_pass(git_reference_resolve(&resolved_ref, reference)); cl_assert_equal_oid(git_reference_target(comp_base_ref), git_reference_target(resolved_ref)); git_reference_free(reference); git_reference_free(resolved_ref); git_reference_free(comp_base_ref); } void test_refs_read__master_then_head(void) { /* lookup the master branch and then the HEAD */ git_reference *reference, *master_ref, *resolved_ref; cl_git_pass(git_reference_lookup(&master_ref, g_repo, current_head_target)); cl_git_pass(git_reference_lookup(&reference, g_repo, GIT_HEAD_FILE)); cl_git_pass(git_reference_resolve(&resolved_ref, reference)); cl_assert_equal_oid(git_reference_target(master_ref), git_reference_target(resolved_ref)); git_reference_free(reference); git_reference_free(resolved_ref); git_reference_free(master_ref); } void test_refs_read__packed(void) { /* lookup a packed reference */ git_reference *reference; git_object *object; cl_git_pass(git_reference_lookup(&reference, g_repo, packed_head_name)); cl_assert(git_reference_type(reference) & GIT_REFERENCE_DIRECT); cl_assert(reference_is_packed(reference)); cl_assert_equal_s(reference->name, packed_head_name); cl_git_pass(git_object_lookup(&object, g_repo, git_reference_target(reference), GIT_OBJECT_ANY)); cl_assert(object != NULL); cl_assert(git_object_type(object) == GIT_OBJECT_COMMIT); git_object_free(object); git_reference_free(reference); } void test_refs_read__loose_first(void) { /* assure that a loose reference is looked up before a packed reference */ git_reference *reference; cl_git_pass(git_reference_lookup(&reference, g_repo, packed_head_name)); git_reference_free(reference); cl_git_pass(git_reference_lookup(&reference, g_repo, packed_test_head_name)); cl_assert(git_reference_type(reference) & GIT_REFERENCE_DIRECT); cl_assert(reference_is_packed(reference) == 0); cl_assert_equal_s(reference->name, packed_test_head_name); git_reference_free(reference); } void test_refs_read__chomped(void) { git_reference *test, *chomped; cl_git_pass(git_reference_lookup(&test, g_repo, "refs/heads/test")); cl_git_pass(git_reference_lookup(&chomped, g_repo, "refs/heads/chomped")); cl_assert_equal_oid(git_reference_target(test), git_reference_target(chomped)); git_reference_free(test); git_reference_free(chomped); } void test_refs_read__trailing(void) { git_reference *test, *trailing; cl_git_pass(git_reference_lookup(&test, g_repo, "refs/heads/test")); cl_git_pass(git_reference_lookup(&trailing, g_repo, "refs/heads/trailing")); cl_assert_equal_oid(git_reference_target(test), git_reference_target(trailing)); git_reference_free(trailing); cl_git_pass(git_reference_lookup(&trailing, g_repo, "FETCH_HEAD")); git_reference_free(test); git_reference_free(trailing); } void test_refs_read__unfound_return_ENOTFOUND(void) { git_reference *reference; git_oid id; cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&reference, g_repo, "TEST_MASTER")); cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&reference, g_repo, "refs/test/master")); cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&reference, g_repo, "refs/tags/test/master")); cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&reference, g_repo, "refs/tags/test/farther/master")); cl_assert_equal_i(GIT_ENOTFOUND, git_reference_name_to_id(&id, g_repo, "refs/tags/test/farther/master")); } static void assert_is_branch(const char *name, bool expected_branchness) { git_reference *reference; cl_git_pass(git_reference_lookup(&reference, g_repo, name)); cl_assert_equal_i(expected_branchness, git_reference_is_branch(reference)); git_reference_free(reference); } void test_refs_read__can_determine_if_a_reference_is_a_local_branch(void) { assert_is_branch("refs/heads/master", true); assert_is_branch("refs/heads/packed", true); assert_is_branch("refs/remotes/test/master", false); assert_is_branch("refs/tags/e90810b", false); } static void assert_is_tag(const char *name, bool expected_tagness) { git_reference *reference; cl_git_pass(git_reference_lookup(&reference, g_repo, name)); cl_assert_equal_i(expected_tagness, git_reference_is_tag(reference)); git_reference_free(reference); } void test_refs_read__can_determine_if_a_reference_is_a_tag(void) { assert_is_tag("refs/tags/e90810b", true); assert_is_tag("refs/tags/test", true); assert_is_tag("refs/heads/packed", false); assert_is_tag("refs/remotes/test/master", false); } static void assert_is_note(const char *name, bool expected_noteness) { git_reference *reference; cl_git_pass(git_reference_lookup(&reference, g_repo, name)); cl_assert_equal_i(expected_noteness, git_reference_is_note(reference)); git_reference_free(reference); } void test_refs_read__can_determine_if_a_reference_is_a_note(void) { assert_is_note("refs/notes/fanout", true); assert_is_note("refs/heads/packed", false); assert_is_note("refs/remotes/test/master", false); } void test_refs_read__invalid_name_returns_EINVALIDSPEC(void) { git_reference *reference; git_oid id; cl_assert_equal_i(GIT_EINVALIDSPEC, git_reference_lookup(&reference, g_repo, "refs/heads/Inv@{id")); cl_assert_equal_i(GIT_EINVALIDSPEC, git_reference_name_to_id(&id, g_repo, "refs/heads/Inv@{id")); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/peel.c
#include "clar_libgit2.h" static git_repository *g_repo; static git_repository *g_peel_repo; void test_refs_peel__initialize(void) { cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git"))); cl_git_pass(git_repository_open(&g_peel_repo, cl_fixture("peeled.git"))); } void test_refs_peel__cleanup(void) { git_repository_free(g_repo); g_repo = NULL; git_repository_free(g_peel_repo); g_peel_repo = NULL; } static void assert_peel_generic( git_repository *repo, const char *ref_name, git_object_t requested_type, const char* expected_sha, git_object_t expected_type) { git_oid expected_oid; git_reference *ref; git_object *peeled; cl_git_pass(git_reference_lookup(&ref, repo, ref_name)); cl_git_pass(git_reference_peel(&peeled, ref, requested_type)); cl_git_pass(git_oid_fromstr(&expected_oid, expected_sha)); cl_assert_equal_oid(&expected_oid, git_object_id(peeled)); cl_assert_equal_i(expected_type, git_object_type(peeled)); git_object_free(peeled); git_reference_free(ref); } static void assert_peel( const char *ref_name, git_object_t requested_type, const char* expected_sha, git_object_t expected_type) { assert_peel_generic(g_repo, ref_name, requested_type, expected_sha, expected_type); } static void assert_peel_error(int error, const char *ref_name, git_object_t requested_type) { git_reference *ref; git_object *peeled; cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name)); cl_assert_equal_i(error, git_reference_peel(&peeled, ref, requested_type)); git_reference_free(ref); } void test_refs_peel__can_peel_a_tag(void) { assert_peel("refs/tags/test", GIT_OBJECT_TAG, "b25fa35b38051e4ae45d4222e795f9df2e43f1d1", GIT_OBJECT_TAG); assert_peel("refs/tags/test", GIT_OBJECT_COMMIT, "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJECT_COMMIT); assert_peel("refs/tags/test", GIT_OBJECT_TREE, "53fc32d17276939fc79ed05badaef2db09990016", GIT_OBJECT_TREE); assert_peel("refs/tags/point_to_blob", GIT_OBJECT_BLOB, "1385f264afb75a56a5bec74243be9b367ba4ca08", GIT_OBJECT_BLOB); } void test_refs_peel__can_peel_a_branch(void) { assert_peel("refs/heads/master", GIT_OBJECT_COMMIT, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_OBJECT_COMMIT); assert_peel("refs/heads/master", GIT_OBJECT_TREE, "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162", GIT_OBJECT_TREE); } void test_refs_peel__can_peel_a_symbolic_reference(void) { assert_peel("HEAD", GIT_OBJECT_COMMIT, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_OBJECT_COMMIT); assert_peel("HEAD", GIT_OBJECT_TREE, "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162", GIT_OBJECT_TREE); } void test_refs_peel__cannot_peel_into_a_non_existing_target(void) { assert_peel_error(GIT_EINVALIDSPEC, "refs/tags/point_to_blob", GIT_OBJECT_TAG); } void test_refs_peel__can_peel_into_any_non_tag_object(void) { assert_peel("refs/heads/master", GIT_OBJECT_ANY, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_OBJECT_COMMIT); assert_peel("refs/tags/point_to_blob", GIT_OBJECT_ANY, "1385f264afb75a56a5bec74243be9b367ba4ca08", GIT_OBJECT_BLOB); assert_peel("refs/tags/test", GIT_OBJECT_ANY, "e90810b8df3e80c413d903f631643c716887138d", GIT_OBJECT_COMMIT); } void test_refs_peel__can_peel_fully_peeled_packed_refs(void) { assert_peel_generic(g_peel_repo, "refs/tags/tag-inside-tags", GIT_OBJECT_ANY, "0df1a5865c8abfc09f1f2182e6a31be550e99f07", GIT_OBJECT_COMMIT); assert_peel_generic(g_peel_repo, "refs/foo/tag-outside-tags", GIT_OBJECT_ANY, "0df1a5865c8abfc09f1f2182e6a31be550e99f07", GIT_OBJECT_COMMIT); } void test_refs_peel__can_peel_fully_peeled_tag_to_tag(void) { assert_peel_generic(g_peel_repo, "refs/tags/tag-inside-tags", GIT_OBJECT_TAG, "c2596aa0151888587ec5c0187f261e63412d9e11", GIT_OBJECT_TAG); assert_peel_generic(g_peel_repo, "refs/foo/tag-outside-tags", GIT_OBJECT_TAG, "c2596aa0151888587ec5c0187f261e63412d9e11", GIT_OBJECT_TAG); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/update.c
#include "clar_libgit2.h" #include "refs.h" static git_repository *g_repo; void test_refs_update__initialize(void) { g_repo = cl_git_sandbox_init("testrepo.git"); } void test_refs_update__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_update__updating_the_target_of_a_symref_with_an_invalid_name_returns_EINVALIDSPEC(void) { git_reference *head; cl_git_pass(git_reference_lookup(&head, g_repo, GIT_HEAD_FILE)); cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(head)); git_reference_free(head); cl_assert_equal_i(GIT_EINVALIDSPEC, git_reference_symbolic_create(&head, g_repo, GIT_HEAD_FILE, "refs/heads/inv@{id", 1, NULL)); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/delete.c
#include "clar_libgit2.h" #include "futils.h" #include "git2/reflog.h" #include "git2/refdb.h" #include "reflog.h" #include "ref_helpers.h" static const char *packed_test_head_name = "refs/heads/packed-test"; static const char *current_master_tip = "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"; static git_repository *g_repo; void test_refs_delete__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); } void test_refs_delete__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_delete__packed_loose(void) { /* deleting a ref which is both packed and loose should remove both tracks in the filesystem */ git_reference *looked_up_ref, *another_looked_up_ref; git_buf temp_path = GIT_BUF_INIT; /* Ensure the loose reference exists on the file system */ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name)); cl_assert(git_path_exists(temp_path.ptr)); /* Lookup the reference */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_test_head_name)); /* Ensure it's the loose version that has been found */ cl_assert(reference_is_packed(looked_up_ref) == 0); /* Now that the reference is deleted... */ cl_git_pass(git_reference_delete(looked_up_ref)); git_reference_free(looked_up_ref); /* Looking up the reference once again should not retrieve it */ cl_git_fail(git_reference_lookup(&another_looked_up_ref, g_repo, packed_test_head_name)); /* Ensure the loose reference doesn't exist any longer on the file system */ cl_assert(!git_path_exists(temp_path.ptr)); git_reference_free(another_looked_up_ref); git_buf_dispose(&temp_path); } void test_refs_delete__packed_only(void) { /* can delete a just packed reference */ git_reference *ref; git_refdb *refdb; git_oid id; const char *new_ref = "refs/heads/new_ref"; git_oid_fromstr(&id, current_master_tip); /* Create and write the new object id reference */ cl_git_pass(git_reference_create(&ref, g_repo, new_ref, &id, 0, NULL)); git_reference_free(ref); /* Lookup the reference */ cl_git_pass(git_reference_lookup(&ref, g_repo, new_ref)); /* Ensure it's a loose reference */ cl_assert(reference_is_packed(ref) == 0); /* Pack all existing references */ cl_git_pass(git_repository_refdb(&refdb, g_repo)); cl_git_pass(git_refdb_compress(refdb)); /* Reload the reference from disk */ git_reference_free(ref); cl_git_pass(git_reference_lookup(&ref, g_repo, new_ref)); /* Ensure it's a packed reference */ cl_assert(reference_is_packed(ref) == 1); /* This should pass */ cl_git_pass(git_reference_delete(ref)); git_reference_free(ref); git_refdb_free(refdb); } void test_refs_delete__remove(void) { git_reference *ref; /* Check that passing no old values lets us delete */ cl_git_pass(git_reference_lookup(&ref, g_repo, packed_test_head_name)); git_reference_free(ref); cl_git_pass(git_reference_remove(g_repo, packed_test_head_name)); cl_git_fail(git_reference_lookup(&ref, g_repo, packed_test_head_name)); } void test_refs_delete__head(void) { git_reference *ref; /* Check that it is not possible to delete HEAD */ cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD")); cl_git_fail(git_reference_delete(ref)); git_reference_free(ref); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/basic.c
#include "clar_libgit2.h" #include "futils.h" #include "refs.h" #include "ref_helpers.h" static git_repository *g_repo; static const char *loose_tag_ref_name = "refs/tags/e90810b"; void test_refs_basic__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); cl_git_pass(git_repository_set_ident(g_repo, "me", "[email protected]")); } void test_refs_basic__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_basic__reference_realloc(void) { git_reference *ref; git_reference *new_ref; const char *new_name = "refs/tags/awful/name-which-is/clearly/really-that-much/longer-than/the-old-one"; /* Retrieval of the reference to rename */ cl_git_pass(git_reference_lookup(&ref, g_repo, loose_tag_ref_name)); new_ref = git_reference__realloc(&ref, new_name); cl_assert(new_ref != NULL); git_reference_free(new_ref); git_reference_free(ref); /* Reload, so we restore the value */ cl_git_pass(git_reference_lookup(&ref, g_repo, loose_tag_ref_name)); cl_git_pass(git_reference_rename(&new_ref, ref, new_name, 1, "log message")); cl_assert(ref != NULL); cl_assert(new_ref != NULL); git_reference_free(new_ref); git_reference_free(ref); } void test_refs_basic__longpaths(void) { #ifdef GIT_WIN32 const char *base; size_t base_len, extra_len; ssize_t remain_len, i; git_buf refname = GIT_BUF_INIT; git_reference *one = NULL, *two = NULL; git_oid id; cl_git_pass(git_oid_fromstr(&id, "099fabac3a9ea935598528c27f866e34089c2eff")); base = git_repository_path(g_repo); base_len = git_utf8_char_length(base, strlen(base)); extra_len = CONST_STRLEN("logs/refs/heads/") + CONST_STRLEN(".lock"); remain_len = (ssize_t)MAX_PATH - (base_len + extra_len); cl_assert(remain_len > 0); cl_git_pass(git_buf_puts(&refname, "refs/heads/")); for (i = 0; i < remain_len; i++) { cl_git_pass(git_buf_putc(&refname, 'a')); } /* * The full path to the reflog lockfile is 260 characters, * this is permitted. */ cl_git_pass(git_reference_create(&one, g_repo, refname.ptr, &id, 0, NULL)); /* Adding one more character gives us a path that is too long. */ cl_git_pass(git_buf_putc(&refname, 'z')); cl_git_fail(git_reference_create(&two, g_repo, refname.ptr, &id, 0, NULL)); git_reference_free(one); git_reference_free(two); git_buf_dispose(&refname); #endif }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/ref_helpers.c
#include "git2/repository.h" #include "git2/refs.h" #include "common.h" #include "util.h" #include "buffer.h" #include "path.h" int reference_is_packed(git_reference *ref) { git_buf ref_path = GIT_BUF_INIT; int packed; assert(ref); if (git_buf_joinpath(&ref_path, git_repository_path(git_reference_owner(ref)), git_reference_name(ref)) < 0) return -1; packed = !git_path_isfile(ref_path.ptr); git_buf_dispose(&ref_path); return packed; }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/ref_helpers.h
int reference_is_packed(git_reference *ref);
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/shorthand.c
#include "clar_libgit2.h" #include "repository.h" void assert_shorthand(git_repository *repo, const char *refname, const char *shorthand) { git_reference *ref; cl_git_pass(git_reference_lookup(&ref, repo, refname)); cl_assert_equal_s(git_reference_shorthand(ref), shorthand); git_reference_free(ref); } void test_refs_shorthand__0(void) { git_repository *repo; cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git"))); assert_shorthand(repo, "refs/heads/master", "master"); assert_shorthand(repo, "refs/tags/test", "test"); assert_shorthand(repo, "refs/remotes/test/master", "test/master"); assert_shorthand(repo, "refs/notes/fanout", "notes/fanout"); git_repository_free(repo); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/iterator.c
#include "clar_libgit2.h" #include "refs.h" #include "vector.h" static git_repository *repo; void test_refs_iterator__initialize(void) { repo = cl_git_sandbox_init("testrepo.git"); } void test_refs_iterator__cleanup(void) { cl_git_sandbox_cleanup(); } static const char *refnames[] = { "refs/blobs/annotated_tag_to_blob", "refs/heads/br2", "refs/heads/cannot-fetch", "refs/heads/chomped", "refs/heads/haacked", "refs/heads/master", "refs/heads/not-good", "refs/heads/packed", "refs/heads/packed-test", "refs/heads/subtrees", "refs/heads/test", "refs/heads/track-local", "refs/heads/trailing", "refs/notes/fanout", "refs/remotes/test/master", "refs/tags/annotated_tag_to_blob", "refs/tags/e90810b", "refs/tags/hard_tag", "refs/tags/point_to_blob", "refs/tags/taggerless", "refs/tags/test", "refs/tags/wrapped_tag", NULL }; static const char *refnames_with_symlink[] = { "refs/blobs/annotated_tag_to_blob", "refs/heads/br2", "refs/heads/cannot-fetch", "refs/heads/chomped", "refs/heads/haacked", "refs/heads/link/a", "refs/heads/link/b", "refs/heads/link/c", "refs/heads/link/d", "refs/heads/master", "refs/heads/not-good", "refs/heads/packed", "refs/heads/packed-test", "refs/heads/subtrees", "refs/heads/test", "refs/heads/track-local", "refs/heads/trailing", "refs/notes/fanout", "refs/remotes/test/master", "refs/tags/annotated_tag_to_blob", "refs/tags/e90810b", "refs/tags/hard_tag", "refs/tags/point_to_blob", "refs/tags/taggerless", "refs/tags/test", "refs/tags/wrapped_tag", NULL }; static int refcmp_cb(const void *a, const void *b) { const git_reference *refa = (const git_reference *)a; const git_reference *refb = (const git_reference *)b; return strcmp(refa->name, refb->name); } static void assert_all_refnames_match(const char **expected, git_vector *names) { size_t i; git_reference *ref; git_vector_sort(names); git_vector_foreach(names, i, ref) { cl_assert(expected[i] != NULL); cl_assert_equal_s(expected[i], ref->name); git_reference_free(ref); } cl_assert(expected[i] == NULL); git_vector_free(names); } void test_refs_iterator__list(void) { git_reference_iterator *iter; git_vector output; git_reference *ref; cl_git_pass(git_vector_init(&output, 33, &refcmp_cb)); cl_git_pass(git_reference_iterator_new(&iter, repo)); while (1) { int error = git_reference_next(&ref, iter); if (error == GIT_ITEROVER) break; cl_git_pass(error); cl_git_pass(git_vector_insert(&output, ref)); } git_reference_iterator_free(iter); assert_all_refnames_match(refnames, &output); } void test_refs_iterator__empty(void) { git_reference_iterator *iter; git_odb *odb; git_reference *ref; git_repository *empty; cl_git_pass(git_odb_new(&odb)); cl_git_pass(git_repository_wrap_odb(&empty, odb)); cl_git_pass(git_reference_iterator_new(&iter, empty)); cl_assert_equal_i(GIT_ITEROVER, git_reference_next(&ref, iter)); git_reference_iterator_free(iter); git_odb_free(odb); git_repository_free(empty); } static int refs_foreach_cb(git_reference *reference, void *payload) { git_vector *output = payload; cl_git_pass(git_vector_insert(output, reference)); return 0; } void test_refs_iterator__foreach(void) { git_vector output; cl_git_pass(git_vector_init(&output, 33, &refcmp_cb)); cl_git_pass(git_reference_foreach(repo, refs_foreach_cb, &output)); assert_all_refnames_match(refnames, &output); } void test_refs_iterator__foreach_through_symlink(void) { git_vector output; #ifdef GIT_WIN32 cl_skip(); #endif cl_git_pass(git_vector_init(&output, 32, &refcmp_cb)); cl_git_pass(p_mkdir("refs", 0777)); cl_git_mkfile("refs/a", "1234567890123456789012345678901234567890"); cl_git_mkfile("refs/b", "1234567890123456789012345678901234567890"); cl_git_mkfile("refs/c", "1234567890123456789012345678901234567890"); cl_git_mkfile("refs/d", "1234567890123456789012345678901234567890"); cl_git_pass(p_symlink("../../../refs", "testrepo.git/refs/heads/link")); cl_git_pass(git_reference_foreach(repo, refs_foreach_cb, &output)); assert_all_refnames_match(refnames_with_symlink, &output); } static int refs_foreach_cancel_cb(git_reference *reference, void *payload) { int *cancel_after = payload; git_reference_free(reference); if (!*cancel_after) return -333; (*cancel_after)--; return 0; } void test_refs_iterator__foreach_can_cancel(void) { int cancel_after = 3; cl_git_fail_with( git_reference_foreach(repo, refs_foreach_cancel_cb, &cancel_after), -333); cl_assert_equal_i(0, cancel_after); } static int refs_foreach_name_cb(const char *name, void *payload) { git_vector *output = payload; cl_git_pass(git_vector_insert(output, git__strdup(name))); return 0; } void test_refs_iterator__foreach_name(void) { git_vector output; size_t i; char *name; cl_git_pass(git_vector_init(&output, 32, &git__strcmp_cb)); cl_git_pass( git_reference_foreach_name(repo, refs_foreach_name_cb, &output)); git_vector_sort(&output); git_vector_foreach(&output, i, name) { cl_assert(refnames[i] != NULL); cl_assert_equal_s(refnames[i], name); git__free(name); } git_vector_free(&output); } static int refs_foreach_name_cancel_cb(const char *name, void *payload) { int *cancel_after = payload; if (!*cancel_after) return -333; GIT_UNUSED(name); (*cancel_after)--; return 0; } void test_refs_iterator__foreach_name_can_cancel(void) { int cancel_after = 5; cl_git_fail_with( git_reference_foreach_name( repo, refs_foreach_name_cancel_cb, &cancel_after), -333); cl_assert_equal_i(0, cancel_after); } void test_refs_iterator__concurrent_delete(void) { git_reference_iterator *iter; size_t full_count = 0, concurrent_count = 0; const char *name; int error; cl_git_sandbox_cleanup(); repo = cl_git_sandbox_init("testrepo"); cl_git_pass(git_reference_iterator_new(&iter, repo)); while ((error = git_reference_next_name(&name, iter)) == 0) { full_count++; } git_reference_iterator_free(iter); cl_assert_equal_i(GIT_ITEROVER, error); cl_git_pass(git_reference_iterator_new(&iter, repo)); while ((error = git_reference_next_name(&name, iter)) == 0) { cl_git_pass(git_reference_remove(repo, name)); concurrent_count++; } git_reference_iterator_free(iter); cl_assert_equal_i(GIT_ITEROVER, error); cl_assert_equal_i(full_count, concurrent_count); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/foreachglob.c
#include "clar_libgit2.h" #include "refs.h" static git_repository *repo; static git_reference *fake_remote; void test_refs_foreachglob__initialize(void) { git_oid id; cl_fixture_sandbox("testrepo.git"); cl_git_pass(git_repository_open(&repo, "testrepo.git")); cl_git_pass(git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644")); cl_git_pass(git_reference_create(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0, NULL)); } void test_refs_foreachglob__cleanup(void) { git_reference_free(fake_remote); fake_remote = NULL; git_repository_free(repo); repo = NULL; cl_fixture_cleanup("testrepo.git"); } static int count_cb(const char *reference_name, void *payload) { int *count = (int *)payload; GIT_UNUSED(reference_name); (*count)++; return 0; } static void assert_retrieval(const char *glob, int expected_count) { int count = 0; cl_git_pass(git_reference_foreach_glob(repo, glob, count_cb, &count)); cl_assert_equal_i(expected_count, count); } void test_refs_foreachglob__retrieve_all_refs(void) { /* 12 heads (including one packed head) + 1 note + 2 remotes + 7 tags + 1 blob */ assert_retrieval("*", 23); } void test_refs_foreachglob__retrieve_remote_branches(void) { assert_retrieval("refs/remotes/*", 2); } void test_refs_foreachglob__retrieve_local_branches(void) { assert_retrieval("refs/heads/*", 12); } void test_refs_foreachglob__retrieve_nonexistant(void) { assert_retrieval("refs/nonexistent/*", 0); } void test_refs_foreachglob__retrieve_partially_named_references(void) { /* * refs/heads/packed-test, refs/heads/test * refs/remotes/test/master, refs/tags/test */ assert_retrieval("*test*", 4); } static int interrupt_cb(const char *reference_name, void *payload) { int *count = (int *)payload; GIT_UNUSED(reference_name); (*count)++; return (*count == 11) ? -1000 : 0; } void test_refs_foreachglob__can_cancel(void) { int count = 0; cl_assert_equal_i(-1000, git_reference_foreach_glob( repo, "*", interrupt_cb, &count) ); cl_assert_equal_i(11, count); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/revparse.c
#include "clar_libgit2.h" #include "git2/revparse.h" #include "buffer.h" #include "refs.h" #include "path.h" static git_repository *g_repo; static git_object *g_obj; /* Helpers */ static void test_object_and_ref_inrepo( const char *spec, const char *expected_oid, const char *expected_refname, git_repository *repo, bool assert_reference_retrieval) { char objstr[64] = {0}; git_object *obj = NULL; git_reference *ref = NULL; int error; error = git_revparse_ext(&obj, &ref, repo, spec); if (expected_oid != NULL) { cl_git_pass(error); git_oid_fmt(objstr, git_object_id(obj)); cl_assert_equal_s(objstr, expected_oid); } else cl_git_fail(error); if (assert_reference_retrieval) { if (expected_refname == NULL) cl_assert(NULL == ref); else cl_assert_equal_s(expected_refname, git_reference_name(ref)); } git_object_free(obj); git_reference_free(ref); } static void test_object_inrepo(const char *spec, const char *expected_oid, git_repository *repo) { test_object_and_ref_inrepo(spec, expected_oid, NULL, repo, false); } static void test_id_inrepo( const char *spec, const char *expected_left, const char *expected_right, git_revspec_t expected_flags, git_repository *repo) { git_revspec revspec; int error = git_revparse(&revspec, repo, spec); if (expected_left) { char str[64] = {0}; cl_assert_equal_i(0, error); git_oid_fmt(str, git_object_id(revspec.from)); cl_assert_equal_s(str, expected_left); git_object_free(revspec.from); } else { cl_assert_equal_i(GIT_ENOTFOUND, error); } if (expected_right) { char str[64] = {0}; git_oid_fmt(str, git_object_id(revspec.to)); cl_assert_equal_s(str, expected_right); git_object_free(revspec.to); } if (expected_flags) cl_assert_equal_i(expected_flags, revspec.flags); } static void test_object(const char *spec, const char *expected_oid) { test_object_inrepo(spec, expected_oid, g_repo); } static void test_object_and_ref(const char *spec, const char *expected_oid, const char *expected_refname) { test_object_and_ref_inrepo(spec, expected_oid, expected_refname, g_repo, true); } static void test_rangelike(const char *rangelike, const char *expected_left, const char *expected_right, git_revspec_t expected_revparseflags) { char objstr[64] = {0}; git_revspec revspec; int error; error = git_revparse(&revspec, g_repo, rangelike); if (expected_left != NULL) { cl_assert_equal_i(0, error); cl_assert_equal_i(revspec.flags, expected_revparseflags); git_oid_fmt(objstr, git_object_id(revspec.from)); cl_assert_equal_s(objstr, expected_left); git_oid_fmt(objstr, git_object_id(revspec.to)); cl_assert_equal_s(objstr, expected_right); } else cl_assert(error != 0); git_object_free(revspec.from); git_object_free(revspec.to); } static void test_id( const char *spec, const char *expected_left, const char *expected_right, git_revspec_t expected_flags) { test_id_inrepo(spec, expected_left, expected_right, expected_flags, g_repo); } static void test_invalid_revspec(const char* invalid_spec) { git_revspec revspec; cl_assert_equal_i( GIT_EINVALIDSPEC, git_revparse(&revspec, g_repo, invalid_spec)); } void test_refs_revparse__initialize(void) { cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git"))); } void test_refs_revparse__cleanup(void) { git_repository_free(g_repo); } void test_refs_revparse__nonexistant_object(void) { test_object("this-does-not-exist", NULL); test_object("this-does-not-exist^1", NULL); test_object("this-does-not-exist~2", NULL); } static void assert_invalid_single_spec(const char *invalid_spec) { cl_assert_equal_i( GIT_EINVALIDSPEC, git_revparse_single(&g_obj, g_repo, invalid_spec)); } void test_refs_revparse__invalid_reference_name(void) { assert_invalid_single_spec("this doesn't make sense"); assert_invalid_single_spec("Inv@{id"); assert_invalid_single_spec(""); } void test_refs_revparse__shas(void) { test_object("c47800c7266a2be04c571c04d5a6614691ea99bd", "c47800c7266a2be04c571c04d5a6614691ea99bd"); test_object("c47800c", "c47800c7266a2be04c571c04d5a6614691ea99bd"); } void test_refs_revparse__head(void) { test_object("HEAD", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("HEAD^0", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("HEAD~0", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("master", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); } void test_refs_revparse__full_refs(void) { test_object("refs/heads/master", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("refs/heads/test", "e90810b8df3e80c413d903f631643c716887138d"); test_object("refs/tags/test", "b25fa35b38051e4ae45d4222e795f9df2e43f1d1"); } void test_refs_revparse__partial_refs(void) { test_object("point_to_blob", "1385f264afb75a56a5bec74243be9b367ba4ca08"); test_object("packed-test", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"); test_object("br2", "a4a7dce85cf63874e984719f4fdd239f5145052f"); } void test_refs_revparse__describe_output(void) { test_object("blah-7-gc47800c", "c47800c7266a2be04c571c04d5a6614691ea99bd"); test_object("not-good", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); } void test_refs_revparse__nth_parent(void) { assert_invalid_single_spec("be3563a^-1"); assert_invalid_single_spec("^"); assert_invalid_single_spec("be3563a^{tree}^"); assert_invalid_single_spec("point_to_blob^{blob}^"); assert_invalid_single_spec("this doesn't make sense^1"); test_object("be3563a^1", "9fd738e8f7967c078dceed8190330fc8648ee56a"); test_object("be3563a^", "9fd738e8f7967c078dceed8190330fc8648ee56a"); test_object("be3563a^2", "c47800c7266a2be04c571c04d5a6614691ea99bd"); test_object("be3563a^1^1", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"); test_object("be3563a^^", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"); test_object("be3563a^2^1", "5b5b025afb0b4c913b4c338a42934a3863bf3644"); test_object("be3563a^0", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("be3563a^{commit}^", "9fd738e8f7967c078dceed8190330fc8648ee56a"); test_object("be3563a^42", NULL); } void test_refs_revparse__not_tag(void) { test_object("point_to_blob^{}", "1385f264afb75a56a5bec74243be9b367ba4ca08"); test_object("wrapped_tag^{}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("master^{}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("master^{tree}^{}", "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162"); test_object("e90810b^{}", "e90810b8df3e80c413d903f631643c716887138d"); test_object("tags/e90810b^{}", "e90810b8df3e80c413d903f631643c716887138d"); test_object("e908^{}", "e90810b8df3e80c413d903f631643c716887138d"); } void test_refs_revparse__to_type(void) { assert_invalid_single_spec("wrapped_tag^{trip}"); test_object("point_to_blob^{commit}", NULL); cl_assert_equal_i( GIT_EPEEL, git_revparse_single(&g_obj, g_repo, "wrapped_tag^{blob}")); test_object("wrapped_tag^{commit}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("wrapped_tag^{tree}", "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162"); test_object("point_to_blob^{blob}", "1385f264afb75a56a5bec74243be9b367ba4ca08"); test_object("master^{commit}^{commit}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); } void test_refs_revparse__linear_history(void) { assert_invalid_single_spec("~"); test_object("foo~bar", NULL); assert_invalid_single_spec("master~bar"); assert_invalid_single_spec("master~-1"); assert_invalid_single_spec("master~0bar"); assert_invalid_single_spec("this doesn't make sense~2"); assert_invalid_single_spec("be3563a^{tree}~"); assert_invalid_single_spec("point_to_blob^{blob}~"); test_object("master~0", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("master~1", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("master~2", "9fd738e8f7967c078dceed8190330fc8648ee56a"); test_object("master~1~1", "9fd738e8f7967c078dceed8190330fc8648ee56a"); test_object("master~~", "9fd738e8f7967c078dceed8190330fc8648ee56a"); } void test_refs_revparse__chaining(void) { assert_invalid_single_spec("master@{0}@{0}"); assert_invalid_single_spec("@{u}@{-1}"); assert_invalid_single_spec("@{-1}@{-1}"); assert_invalid_single_spec("@{-3}@{0}"); test_object("master@{0}~1^1", "9fd738e8f7967c078dceed8190330fc8648ee56a"); test_object("@{u}@{0}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("@{-1}@{0}", "a4a7dce85cf63874e984719f4fdd239f5145052f"); test_object("@{-4}@{1}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("master~1^1", "9fd738e8f7967c078dceed8190330fc8648ee56a"); test_object("master~1^2", "c47800c7266a2be04c571c04d5a6614691ea99bd"); test_object("master^1^2~1", "5b5b025afb0b4c913b4c338a42934a3863bf3644"); test_object("master^^2^", "5b5b025afb0b4c913b4c338a42934a3863bf3644"); test_object("master^1^1^1^1^1", "8496071c1b46c854b31185ea97743be6a8774479"); test_object("master^^1^2^1", NULL); } void test_refs_revparse__upstream(void) { assert_invalid_single_spec("e90810b@{u}"); assert_invalid_single_spec("refs/tags/e90810b@{u}"); test_object("refs/heads/e90810b@{u}", NULL); test_object("master@{upstream}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("@{u}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("master@{u}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("heads/master@{u}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("refs/heads/master@{u}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); } void test_refs_revparse__ordinal(void) { assert_invalid_single_spec("master@{-2}"); /* TODO: make the test below actually fail * cl_git_fail(git_revparse_single(&g_obj, g_repo, "master@{1a}")); */ test_object("nope@{0}", NULL); test_object("master@{31415}", NULL); test_object("@{1000}", NULL); test_object("@{2}", NULL); test_object("@{0}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("@{1}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("master@{0}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("master@{1}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("heads/master@{1}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("refs/heads/master@{1}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); } void test_refs_revparse__previous_head(void) { assert_invalid_single_spec("@{-xyz}"); assert_invalid_single_spec("@{-0}"); assert_invalid_single_spec("@{-1b}"); test_object("@{-42}", NULL); test_object("@{-2}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("@{-1}", "a4a7dce85cf63874e984719f4fdd239f5145052f"); } static void create_fake_stash_reference_and_reflog(git_repository *repo) { git_reference *master, *new_master; git_buf log_path = GIT_BUF_INIT; git_buf_joinpath(&log_path, git_repository_path(repo), "logs/refs/fakestash"); cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&log_path))); cl_git_pass(git_reference_lookup(&master, repo, "refs/heads/master")); cl_git_pass(git_reference_rename(&new_master, master, "refs/fakestash", 0, NULL)); git_reference_free(master); cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&log_path))); git_buf_dispose(&log_path); git_reference_free(new_master); } void test_refs_revparse__reflog_of_a_ref_under_refs(void) { git_repository *repo = cl_git_sandbox_init("testrepo.git"); test_object_inrepo("refs/fakestash", NULL, repo); create_fake_stash_reference_and_reflog(repo); /* * $ git reflog -1 refs/fakestash * a65fedf refs/fakestash@{0}: commit: checking in * * $ git reflog -1 refs/fakestash@{0} * a65fedf refs/fakestash@{0}: commit: checking in * * $ git reflog -1 fakestash * a65fedf fakestash@{0}: commit: checking in * * $ git reflog -1 fakestash@{0} * a65fedf fakestash@{0}: commit: checking in */ test_object_inrepo("refs/fakestash", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", repo); test_object_inrepo("refs/fakestash@{0}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", repo); test_object_inrepo("fakestash", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", repo); test_object_inrepo("fakestash@{0}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", repo); cl_git_sandbox_cleanup(); } void test_refs_revparse__revwalk(void) { test_object("master^{/not found in any commit}", NULL); test_object("master^{/merge}", NULL); assert_invalid_single_spec("master^{/((}"); test_object("master^{/anoth}", "5b5b025afb0b4c913b4c338a42934a3863bf3644"); test_object("master^{/Merge}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("br2^{/Merge}", "a4a7dce85cf63874e984719f4fdd239f5145052f"); test_object("master^{/fo.rth}", "9fd738e8f7967c078dceed8190330fc8648ee56a"); } void test_refs_revparse__date(void) { /* * $ git reflog HEAD --date=iso * a65fedf HEAD@{2012-04-30 08:23:41 -0900}: checkout: moving from br2 to master * a4a7dce HEAD@{2012-04-30 08:23:37 -0900}: commit: checking in * c47800c HEAD@{2012-04-30 08:23:28 -0900}: checkout: moving from master to br2 * a65fedf HEAD@{2012-04-30 08:23:23 -0900}: commit: * be3563a HEAD@{2012-04-30 10:22:43 -0700}: clone: from /Users/ben/src/libgit2/tes * * $ git reflog HEAD --date=raw * a65fedf HEAD@{1335806621 -0900}: checkout: moving from br2 to master * a4a7dce HEAD@{1335806617 -0900}: commit: checking in * c47800c HEAD@{1335806608 -0900}: checkout: moving from master to br2 * a65fedf HEAD@{1335806603 -0900}: commit: * be3563a HEAD@{1335806563 -0700}: clone: from /Users/ben/src/libgit2/tests/resour */ test_object("HEAD@{10 years ago}", NULL); test_object("HEAD@{1 second}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("HEAD@{1 second ago}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("HEAD@{2 days ago}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); /* * $ git reflog master --date=iso * a65fedf master@{2012-04-30 09:23:23 -0800}: commit: checking in * be3563a master@{2012-04-30 09:22:43 -0800}: clone: from /Users/ben/src... * * $ git reflog master --date=raw * a65fedf master@{1335806603 -0800}: commit: checking in * be3563a master@{1335806563 -0800}: clone: from /Users/ben/src/libgit2/tests/reso */ /* * $ git reflog -1 "master@{2012-04-30 17:22:42 +0000}" * warning: Log for 'master' only goes back to Mon, 30 Apr 2012 09:22:43 -0800. */ test_object("master@{2012-04-30 17:22:42 +0000}", NULL); test_object("master@{2012-04-30 09:22:42 -0800}", NULL); /* * $ git reflog -1 "master@{2012-04-30 17:22:43 +0000}" * be3563a master@{Mon Apr 30 09:22:43 2012 -0800}: clone: from /Users/ben/src/libg */ test_object("master@{2012-04-30 17:22:43 +0000}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); test_object("master@{2012-04-30 09:22:43 -0800}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); /* * $ git reflog -1 "master@{2012-4-30 09:23:27 -0800}" * a65fedf master@{Mon Apr 30 09:23:23 2012 -0800}: commit: checking in */ test_object("master@{2012-4-30 09:23:27 -0800}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); /* * $ git reflog -1 master@{2012-05-03} * a65fedf master@{Mon Apr 30 09:23:23 2012 -0800}: commit: checking in */ test_object("master@{2012-05-03}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); /* * $ git reflog -1 "master@{1335806603}" * a65fedf * * $ git reflog -1 "master@{1335806602}" * be3563a */ test_object("master@{1335806603}", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("master@{1335806602}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); } void test_refs_revparse__colon(void) { assert_invalid_single_spec(":/"); assert_invalid_single_spec("point_to_blob:readme.txt"); cl_git_fail(git_revparse_single(&g_obj, g_repo, ":2:README")); /* Not implemented */ test_object(":/not found in any commit", NULL); test_object("subtrees:ab/42.txt", NULL); test_object("subtrees:ab/4.txt/nope", NULL); test_object("subtrees:nope", NULL); test_object("test/master^1:branch_file.txt", NULL); /* From tags */ test_object("test:readme.txt", "0266163a49e280c4f5ed1e08facd36a2bd716bcf"); test_object("tags/test:readme.txt", "0266163a49e280c4f5ed1e08facd36a2bd716bcf"); test_object("e90810b:readme.txt", "0266163a49e280c4f5ed1e08facd36a2bd716bcf"); test_object("tags/e90810b:readme.txt", "0266163a49e280c4f5ed1e08facd36a2bd716bcf"); /* From commits */ test_object("a65f:branch_file.txt", "3697d64be941a53d4ae8f6a271e4e3fa56b022cc"); /* From trees */ test_object("a65f^{tree}:branch_file.txt", "3697d64be941a53d4ae8f6a271e4e3fa56b022cc"); test_object("944c:branch_file.txt", "3697d64be941a53d4ae8f6a271e4e3fa56b022cc"); /* Retrieving trees */ test_object("master:", "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162"); test_object("subtrees:", "ae90f12eea699729ed24555e40b9fd669da12a12"); test_object("subtrees:ab", "f1425cef211cc08caa31e7b545ffb232acb098c3"); test_object("subtrees:ab/", "f1425cef211cc08caa31e7b545ffb232acb098c3"); /* Retrieving blobs */ test_object("subtrees:ab/4.txt", "d6c93164c249c8000205dd4ec5cbca1b516d487f"); test_object("subtrees:ab/de/fgh/1.txt", "1f67fc4386b2d171e0d21be1c447e12660561f9b"); test_object("master:README", "a8233120f6ad708f843d861ce2b7228ec4e3dec6"); test_object("master:new.txt", "a71586c1dfe8a71c6cbf6c129f404c5642ff31bd"); test_object(":/Merge", "a4a7dce85cf63874e984719f4fdd239f5145052f"); test_object(":/one", "c47800c7266a2be04c571c04d5a6614691ea99bd"); test_object(":/packed commit t", "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9"); test_object("test/master^2:branch_file.txt", "45b983be36b73c0788dc9cbcb76cbb80fc7bb057"); test_object("test/master@{1}:branch_file.txt", "3697d64be941a53d4ae8f6a271e4e3fa56b022cc"); } void test_refs_revparse__disambiguation(void) { /* * $ git show e90810b * tag e90810b * Tagger: Vicent Marti <[email protected]> * Date: Thu Aug 12 03:59:17 2010 +0200 * * This is a very simple tag. * * commit e90810b8df3e80c413d903f631643c716887138d * Author: Vicent Marti <[email protected]> * Date: Thu Aug 5 18:42:20 2010 +0200 * * Test commit 2 * * diff --git a/readme.txt b/readme.txt * index 6336846..0266163 100644 * --- a/readme.txt * +++ b/readme.txt * @@ -1 +1,2 @@ * Testing a readme.txt * +Now we add a single line here * * $ git show-ref e90810b * 7b4384978d2493e851f9cca7858815fac9b10980 refs/tags/e90810b * */ test_object("e90810b", "7b4384978d2493e851f9cca7858815fac9b10980"); /* * $ git show e90810 * commit e90810b8df3e80c413d903f631643c716887138d * Author: Vicent Marti <[email protected]> * Date: Thu Aug 5 18:42:20 2010 +0200 * * Test commit 2 * * diff --git a/readme.txt b/readme.txt * index 6336846..0266163 100644 * --- a/readme.txt * +++ b/readme.txt * @@ -1 +1,2 @@ * Testing a readme.txt * +Now we add a single line here */ test_object("e90810", "e90810b8df3e80c413d903f631643c716887138d"); } void test_refs_revparse__a_too_short_objectid_returns_EAMBIGUOUS(void) { cl_assert_equal_i( GIT_EAMBIGUOUS, git_revparse_single(&g_obj, g_repo, "e90")); } /* * $ echo "aabqhq" | git hash-object -t blob --stdin * dea509d0b3cb8ee0650f6ca210bc83f4678851ba * * $ echo "aaazvc" | git hash-object -t blob --stdin * dea509d097ce692e167dfc6a48a7a280cc5e877e */ void test_refs_revparse__a_not_precise_enough_objectid_returns_EAMBIGUOUS(void) { git_repository *repo; git_index *index; git_object *obj; repo = cl_git_sandbox_init("testrepo"); cl_git_mkfile("testrepo/one.txt", "aabqhq\n"); cl_git_mkfile("testrepo/two.txt", "aaazvc\n"); cl_git_pass(git_repository_index(&index, repo)); cl_git_pass(git_index_add_bypath(index, "one.txt")); cl_git_pass(git_index_add_bypath(index, "two.txt")); cl_git_fail_with(git_revparse_single(&obj, repo, "dea509d0"), GIT_EAMBIGUOUS); cl_git_pass(git_revparse_single(&obj, repo, "dea509d09")); git_object_free(obj); git_index_free(index); cl_git_sandbox_cleanup(); } void test_refs_revparse__issue_994(void) { git_repository *repo; git_reference *head, *with_at; git_object *target; repo = cl_git_sandbox_init("testrepo.git"); cl_assert_equal_i(GIT_ENOTFOUND, git_revparse_single(&target, repo, "origin/bim_with_3d@11296")); cl_assert_equal_i(GIT_ENOTFOUND, git_revparse_single(&target, repo, "refs/remotes/origin/bim_with_3d@11296")); cl_git_pass(git_repository_head(&head, repo)); cl_git_pass(git_reference_create( &with_at, repo, "refs/remotes/origin/bim_with_3d@11296", git_reference_target(head), 0, NULL)); cl_git_pass(git_revparse_single(&target, repo, "origin/bim_with_3d@11296")); git_object_free(target); cl_git_pass(git_revparse_single(&target, repo, "refs/remotes/origin/bim_with_3d@11296")); git_object_free(target); git_reference_free(with_at); git_reference_free(head); cl_git_sandbox_cleanup(); } /** * $ git rev-parse blah-7-gc47800c * c47800c7266a2be04c571c04d5a6614691ea99bd * * $ git rev-parse HEAD~3 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 * * $ git branch blah-7-gc47800c HEAD~3 * * $ git rev-parse blah-7-gc47800c * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 */ void test_refs_revparse__try_to_retrieve_branch_before_described_tag(void) { git_repository *repo; git_reference *branch; git_object *target; char sha[GIT_OID_HEXSZ + 1]; repo = cl_git_sandbox_init("testrepo.git"); test_object_inrepo("blah-7-gc47800c", "c47800c7266a2be04c571c04d5a6614691ea99bd", repo); cl_git_pass(git_revparse_single(&target, repo, "HEAD~3")); cl_git_pass(git_branch_create(&branch, repo, "blah-7-gc47800c", (git_commit *)target, 0)); git_oid_tostr(sha, GIT_OID_HEXSZ + 1, git_object_id(target)); test_object_inrepo("blah-7-gc47800c", sha, repo); git_reference_free(branch); git_object_free(target); cl_git_sandbox_cleanup(); } /** * $ git rev-parse a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * * $ git rev-parse HEAD~3 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 * * $ git branch a65fedf39aefe402d3bb6e24df4d4f5fe4547750 HEAD~3 * * $ git rev-parse a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * * $ git rev-parse heads/a65fedf39aefe402d3bb6e24df4d4f5fe4547750 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 */ void test_refs_revparse__try_to_retrieve_sha_before_branch(void) { git_repository *repo; git_reference *branch; git_object *target; char sha[GIT_OID_HEXSZ + 1]; repo = cl_git_sandbox_init("testrepo.git"); test_object_inrepo("a65fedf39aefe402d3bb6e24df4d4f5fe4547750", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", repo); cl_git_pass(git_revparse_single(&target, repo, "HEAD~3")); cl_git_pass(git_branch_create(&branch, repo, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", (git_commit *)target, 0)); git_oid_tostr(sha, GIT_OID_HEXSZ + 1, git_object_id(target)); test_object_inrepo("a65fedf39aefe402d3bb6e24df4d4f5fe4547750", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", repo); test_object_inrepo("heads/a65fedf39aefe402d3bb6e24df4d4f5fe4547750", sha, repo); git_reference_free(branch); git_object_free(target); cl_git_sandbox_cleanup(); } /** * $ git rev-parse c47800 * c47800c7266a2be04c571c04d5a6614691ea99bd * * $ git rev-parse HEAD~3 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 * * $ git branch c47800 HEAD~3 * * $ git rev-parse c47800 * 4a202b346bb0fb0db7eff3cffeb3c70babbd2045 */ void test_refs_revparse__try_to_retrieve_branch_before_abbrev_sha(void) { git_repository *repo; git_reference *branch; git_object *target; char sha[GIT_OID_HEXSZ + 1]; repo = cl_git_sandbox_init("testrepo.git"); test_object_inrepo("c47800", "c47800c7266a2be04c571c04d5a6614691ea99bd", repo); cl_git_pass(git_revparse_single(&target, repo, "HEAD~3")); cl_git_pass(git_branch_create(&branch, repo, "c47800", (git_commit *)target, 0)); git_oid_tostr(sha, GIT_OID_HEXSZ + 1, git_object_id(target)); test_object_inrepo("c47800", sha, repo); git_reference_free(branch); git_object_free(target); cl_git_sandbox_cleanup(); } void test_refs_revparse__range(void) { assert_invalid_single_spec("be3563a^1..be3563a"); test_rangelike("be3563a^1..be3563a", "9fd738e8f7967c078dceed8190330fc8648ee56a", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644", GIT_REVSPEC_RANGE); test_rangelike("be3563a^1...be3563a", "9fd738e8f7967c078dceed8190330fc8648ee56a", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644", GIT_REVSPEC_RANGE | GIT_REVSPEC_MERGE_BASE); test_rangelike("be3563a^1.be3563a", NULL, NULL, 0); } void test_refs_revparse__parses_range_operator(void) { test_id("HEAD", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", NULL, GIT_REVSPEC_SINGLE); test_id("HEAD~3..HEAD", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_REVSPEC_RANGE); test_id("HEAD~3...HEAD", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_REVSPEC_RANGE | GIT_REVSPEC_MERGE_BASE); test_id("HEAD~3..", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_REVSPEC_RANGE); test_id("HEAD~3...", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_REVSPEC_RANGE | GIT_REVSPEC_MERGE_BASE); test_id("..HEAD~3", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", GIT_REVSPEC_RANGE); test_id("...HEAD~3", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", GIT_REVSPEC_RANGE | GIT_REVSPEC_MERGE_BASE); test_id("...", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", GIT_REVSPEC_RANGE | GIT_REVSPEC_MERGE_BASE); test_invalid_revspec(".."); } void test_refs_revparse__ext_retrieves_both_the_reference_and_its_target(void) { test_object_and_ref( "master@{upstream}", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644", "refs/remotes/test/master"); test_object_and_ref( "@{-1}", "a4a7dce85cf63874e984719f4fdd239f5145052f", "refs/heads/br2"); } void test_refs_revparse__ext_can_expand_short_reference_names(void) { test_object_and_ref( "master", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", "refs/heads/master"); test_object_and_ref( "HEAD", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", "refs/heads/master"); test_object_and_ref( "tags/test", "b25fa35b38051e4ae45d4222e795f9df2e43f1d1", "refs/tags/test"); } void test_refs_revparse__ext_returns_NULL_reference_when_expression_points_at_a_revision(void) { test_object_and_ref( "HEAD~3", "4a202b346bb0fb0db7eff3cffeb3c70babbd2045", NULL); test_object_and_ref( "HEAD~0", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", NULL); test_object_and_ref( "HEAD^0", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", NULL); test_object_and_ref( "@{-1}@{0}", "a4a7dce85cf63874e984719f4fdd239f5145052f", NULL); } void test_refs_revparse__ext_returns_NULL_reference_when_expression_points_at_a_tree_content(void) { test_object_and_ref( "tags/test:readme.txt", "0266163a49e280c4f5ed1e08facd36a2bd716bcf", NULL); } void test_refs_revparse__uneven_sizes(void) { test_object("a65fedf39aefe402d3bb6e24df4d4f5fe454775", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("a65fedf39aefe402d3bb6e24df4d4f5fe45477", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("a65fedf39aefe402d3bb6e24df4d4f5fe4547", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); test_object("a65fedf39aefe402d3bb6e24df4d", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/listall.c
#include "clar_libgit2.h" #include "posix.h" static git_repository *repo; static git_strarray ref_list; static void ensure_no_refname_starts_with_a_forward_slash(const char *path) { size_t i; cl_git_pass(git_repository_open(&repo, path)); cl_git_pass(git_reference_list(&ref_list, repo)); cl_assert(ref_list.count > 0); for (i = 0; i < ref_list.count; i++) cl_assert(git__prefixcmp(ref_list.strings[i], "/") != 0); git_strarray_dispose(&ref_list); git_repository_free(repo); } void test_refs_listall__from_repository_opened_through_workdir_path(void) { cl_fixture_sandbox("status"); cl_git_pass(p_rename("status/.gitted", "status/.git")); ensure_no_refname_starts_with_a_forward_slash("status"); cl_fixture_cleanup("status"); } void test_refs_listall__from_repository_opened_through_gitdir_path(void) { ensure_no_refname_starts_with_a_forward_slash(cl_fixture("testrepo.git")); } void test_refs_listall__from_repository_with_no_trailing_newline(void) { cl_git_pass(git_repository_open(&repo, cl_fixture("bad_tag.git"))); cl_git_pass(git_reference_list(&ref_list, repo)); cl_assert(ref_list.count > 0); git_strarray_dispose(&ref_list); git_repository_free(repo); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/dup.c
#include "clar_libgit2.h" #include "refs.h" static git_repository *g_repo; void test_refs_dup__initialize(void) { g_repo = cl_git_sandbox_init("testrepo.git"); } void test_refs_dup__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_dup__direct(void) { git_reference *a, *b; cl_git_pass(git_reference_lookup(&a, g_repo, "refs/heads/master")); cl_git_pass(git_reference_dup(&b, a)); cl_assert(git_reference_cmp(a, b) == 0); cl_assert(git_reference_owner(b) == g_repo); git_reference_free(b); git_reference_free(a); } void test_refs_dup__symbolic(void) { git_reference *a, *b; cl_git_pass(git_reference_lookup(&a, g_repo, "HEAD")); cl_git_pass(git_reference_dup(&b, a)); cl_assert(git_reference_cmp(a, b) == 0); cl_assert(git_reference_owner(b) == g_repo); git_reference_free(b); git_reference_free(a); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/lookup.c
#include "clar_libgit2.h" #include "refs.h" static git_repository *g_repo; void test_refs_lookup__initialize(void) { g_repo = cl_git_sandbox_init("testrepo.git"); } void test_refs_lookup__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_lookup__with_resolve(void) { git_reference *a, *b, *temp; cl_git_pass(git_reference_lookup(&temp, g_repo, "HEAD")); cl_git_pass(git_reference_resolve(&a, temp)); git_reference_free(temp); cl_git_pass(git_reference_lookup_resolved(&b, g_repo, "HEAD", 5)); cl_assert(git_reference_cmp(a, b) == 0); git_reference_free(b); cl_git_pass(git_reference_lookup_resolved(&b, g_repo, "HEAD_TRACKER", 5)); cl_assert(git_reference_cmp(a, b) == 0); git_reference_free(b); git_reference_free(a); } void test_refs_lookup__invalid_name(void) { git_oid oid; cl_git_fail(git_reference_name_to_id(&oid, g_repo, "/refs/tags/point_to_blob")); } void test_refs_lookup__oid(void) { git_oid tag, expected; cl_git_pass(git_reference_name_to_id(&tag, g_repo, "refs/tags/point_to_blob")); cl_git_pass(git_oid_fromstr(&expected, "1385f264afb75a56a5bec74243be9b367ba4ca08")); cl_assert_equal_oid(&expected, &tag); } void test_refs_lookup__namespace(void) { int error; git_reference *ref; error = git_reference_lookup(&ref, g_repo, "refs/heads"); cl_assert_equal_i(error, GIT_ENOTFOUND); error = git_reference_lookup(&ref, g_repo, "refs/heads/"); cl_assert_equal_i(error, GIT_EINVALIDSPEC); } void test_refs_lookup__dwim_notfound(void) { git_reference *ref; cl_git_fail_with(GIT_ENOTFOUND, git_reference_dwim(&ref, g_repo, "idontexist")); cl_assert_equal_s("no reference found for shorthand 'idontexist'", git_error_last()->message); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/rename.c
#include "clar_libgit2.h" #include "futils.h" #include "git2/reflog.h" #include "reflog.h" #include "refs.h" #include "ref_helpers.h" static const char *loose_tag_ref_name = "refs/tags/e90810b"; static const char *packed_head_name = "refs/heads/packed"; static const char *packed_test_head_name = "refs/heads/packed-test"; static const char *ref_one_name = "refs/heads/one/branch"; static const char *ref_one_name_new = "refs/heads/two/branch"; static const char *ref_two_name = "refs/heads/two"; static const char *ref_master_name = "refs/heads/master"; static const char *ref_two_name_new = "refs/heads/two/two"; static git_repository *g_repo; void test_refs_rename__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); cl_git_pass(git_repository_set_ident(g_repo, "me", "[email protected]")); } void test_refs_rename__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_rename__loose(void) { /* rename a loose reference */ git_reference *looked_up_ref, *new_ref, *another_looked_up_ref; git_buf temp_path = GIT_BUF_INIT; const char *new_name = "refs/tags/Nemo/knows/refs.kung-fu"; /* Ensure the ref doesn't exist on the file system */ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), new_name)); cl_assert(!git_path_exists(temp_path.ptr)); /* Retrieval of the reference to rename */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, loose_tag_ref_name)); /* ... which is indeed loose */ cl_assert(reference_is_packed(looked_up_ref) == 0); /* Now that the reference is renamed... */ cl_git_pass(git_reference_rename(&new_ref, looked_up_ref, new_name, 0, NULL)); cl_assert_equal_s(new_ref->name, new_name); git_reference_free(looked_up_ref); /* ...It can't be looked-up with the old name... */ cl_git_fail(git_reference_lookup(&another_looked_up_ref, g_repo, loose_tag_ref_name)); /* ...but the new name works ok... */ cl_git_pass(git_reference_lookup(&another_looked_up_ref, g_repo, new_name)); cl_assert_equal_s(new_ref->name, new_name); /* .. the new ref is loose... */ cl_assert(reference_is_packed(another_looked_up_ref) == 0); cl_assert(reference_is_packed(new_ref) == 0); /* ...and the ref can be found in the file system */ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), new_name)); cl_assert(git_path_exists(temp_path.ptr)); git_reference_free(new_ref); git_reference_free(another_looked_up_ref); git_buf_dispose(&temp_path); } void test_refs_rename__packed(void) { /* rename a packed reference (should make it loose) */ git_reference *looked_up_ref, *new_ref, *another_looked_up_ref; git_buf temp_path = GIT_BUF_INIT; const char *brand_new_name = "refs/heads/brand_new_name"; /* Ensure the ref doesn't exist on the file system */ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_head_name)); cl_assert(!git_path_exists(temp_path.ptr)); /* The reference can however be looked-up... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_head_name)); /* .. and it's packed */ cl_assert(reference_is_packed(looked_up_ref) != 0); /* Now that the reference is renamed... */ cl_git_pass(git_reference_rename(&new_ref, looked_up_ref, brand_new_name, 0, NULL)); cl_assert_equal_s(new_ref->name, brand_new_name); git_reference_free(looked_up_ref); /* ...It can't be looked-up with the old name... */ cl_git_fail(git_reference_lookup(&another_looked_up_ref, g_repo, packed_head_name)); /* ...but the new name works ok... */ cl_git_pass(git_reference_lookup(&another_looked_up_ref, g_repo, brand_new_name)); cl_assert_equal_s(another_looked_up_ref->name, brand_new_name); /* .. the ref is no longer packed... */ cl_assert(reference_is_packed(another_looked_up_ref) == 0); cl_assert(reference_is_packed(new_ref) == 0); /* ...and the ref now happily lives in the file system */ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), brand_new_name)); cl_assert(git_path_exists(temp_path.ptr)); git_reference_free(new_ref); git_reference_free(another_looked_up_ref); git_buf_dispose(&temp_path); } void test_refs_rename__packed_doesnt_pack_others(void) { /* renaming a packed reference does not pack another reference which happens to be in both loose and pack state */ git_reference *looked_up_ref, *another_looked_up_ref, *renamed_ref; git_buf temp_path = GIT_BUF_INIT; const char *brand_new_name = "refs/heads/brand_new_name"; /* Ensure the other reference exists on the file system */ cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name)); cl_assert(git_path_exists(temp_path.ptr)); /* Lookup the other reference */ cl_git_pass(git_reference_lookup(&another_looked_up_ref, g_repo, packed_test_head_name)); /* Ensure it's loose */ cl_assert(reference_is_packed(another_looked_up_ref) == 0); git_reference_free(another_looked_up_ref); /* Lookup the reference to rename */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_head_name)); /* Ensure it's packed */ cl_assert(reference_is_packed(looked_up_ref) != 0); /* Now that the reference is renamed... */ cl_git_pass(git_reference_rename(&renamed_ref, looked_up_ref, brand_new_name, 0, NULL)); git_reference_free(looked_up_ref); /* Lookup the other reference */ cl_git_pass(git_reference_lookup(&another_looked_up_ref, g_repo, packed_test_head_name)); /* Ensure it's loose */ cl_assert(reference_is_packed(another_looked_up_ref) == 0); /* Ensure the other ref still exists on the file system */ cl_assert(git_path_exists(temp_path.ptr)); git_reference_free(renamed_ref); git_reference_free(another_looked_up_ref); git_buf_dispose(&temp_path); } void test_refs_rename__name_collision(void) { /* can not rename a reference with the name of an existing reference */ git_reference *looked_up_ref, *renamed_ref; /* An existing reference... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_head_name)); /* Can not be renamed to the name of another existing reference. */ cl_git_fail(git_reference_rename(&renamed_ref, looked_up_ref, packed_test_head_name, 0, NULL)); git_reference_free(looked_up_ref); /* Failure to rename it hasn't corrupted its state */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_head_name)); cl_assert_equal_s(looked_up_ref->name, packed_head_name); git_reference_free(looked_up_ref); } void test_refs_rename__invalid_name(void) { /* can not rename a reference with an invalid name */ git_reference *looked_up_ref, *renamed_ref; /* An existing oid reference... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_test_head_name)); /* Can not be renamed with an invalid name. */ cl_assert_equal_i( GIT_EINVALIDSPEC, git_reference_rename(&renamed_ref, looked_up_ref, "Hello! I'm a very invalid name.", 0, NULL)); /* Can not be renamed outside of the refs hierarchy * unless it's ALL_CAPS_AND_UNDERSCORES. */ cl_assert_equal_i(GIT_EINVALIDSPEC, git_reference_rename(&renamed_ref, looked_up_ref, "i-will-sudo-you", 0, NULL)); /* Failure to rename it hasn't corrupted its state */ git_reference_free(looked_up_ref); cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_test_head_name)); cl_assert_equal_s(looked_up_ref->name, packed_test_head_name); git_reference_free(looked_up_ref); } void test_refs_rename__force_loose_packed(void) { /* can force-rename a packed reference with the name of an existing loose and packed reference */ git_reference *looked_up_ref, *renamed_ref; git_oid oid; /* An existing reference... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_head_name)); git_oid_cpy(&oid, git_reference_target(looked_up_ref)); /* Can be force-renamed to the name of another existing reference. */ cl_git_pass(git_reference_rename(&renamed_ref, looked_up_ref, packed_test_head_name, 1, NULL)); git_reference_free(looked_up_ref); git_reference_free(renamed_ref); /* Check we actually renamed it */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, packed_test_head_name)); cl_assert_equal_s(looked_up_ref->name, packed_test_head_name); cl_assert_equal_oid(&oid, git_reference_target(looked_up_ref)); git_reference_free(looked_up_ref); /* And that the previous one doesn't exist any longer */ cl_git_fail(git_reference_lookup(&looked_up_ref, g_repo, packed_head_name)); } void test_refs_rename__force_loose(void) { /* can force-rename a loose reference with the name of an existing loose reference */ git_reference *looked_up_ref, *renamed_ref; git_oid oid; /* An existing reference... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, "refs/heads/br2")); git_oid_cpy(&oid, git_reference_target(looked_up_ref)); /* Can be force-renamed to the name of another existing reference. */ cl_git_pass(git_reference_rename(&renamed_ref, looked_up_ref, "refs/heads/test", 1, NULL)); git_reference_free(looked_up_ref); git_reference_free(renamed_ref); /* Check we actually renamed it */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, "refs/heads/test")); cl_assert_equal_s(looked_up_ref->name, "refs/heads/test"); cl_assert_equal_oid(&oid, git_reference_target(looked_up_ref)); git_reference_free(looked_up_ref); /* And that the previous one doesn't exist any longer */ cl_git_fail(git_reference_lookup(&looked_up_ref, g_repo, "refs/heads/br2")); git_reference_free(looked_up_ref); } void test_refs_rename__overwrite(void) { /* can not overwrite name of existing reference */ git_reference *ref, *ref_one, *ref_one_new, *ref_two; git_refdb *refdb; git_oid id; cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_DIRECT); git_oid_cpy(&id, git_reference_target(ref)); /* Create loose references */ cl_git_pass(git_reference_create(&ref_one, g_repo, ref_one_name, &id, 0, NULL)); cl_git_pass(git_reference_create(&ref_two, g_repo, ref_two_name, &id, 0, NULL)); /* Pack everything */ cl_git_pass(git_repository_refdb(&refdb, g_repo)); cl_git_pass(git_refdb_compress(refdb)); /* Attempt to create illegal reference */ cl_git_fail(git_reference_create(&ref_one_new, g_repo, ref_one_name_new, &id, 0, NULL)); /* Illegal reference couldn't be created so this is supposed to fail */ cl_git_fail(git_reference_lookup(&ref_one_new, g_repo, ref_one_name_new)); git_reference_free(ref); git_reference_free(ref_one); git_reference_free(ref_one_new); git_reference_free(ref_two); git_refdb_free(refdb); } void test_refs_rename__prefix(void) { /* can be renamed to a new name prefixed with the old name */ git_reference *ref, *ref_two, *looked_up_ref, *renamed_ref; git_oid id; cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_DIRECT); git_oid_cpy(&id, git_reference_target(ref)); /* Create loose references */ cl_git_pass(git_reference_create(&ref_two, g_repo, ref_two_name, &id, 0, NULL)); /* An existing reference... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name)); /* Can be rename to a new name starting with the old name. */ cl_git_pass(git_reference_rename(&renamed_ref, looked_up_ref, ref_two_name_new, 0, NULL)); git_reference_free(looked_up_ref); git_reference_free(renamed_ref); /* Check we actually renamed it */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name_new)); cl_assert_equal_s(looked_up_ref->name, ref_two_name_new); git_reference_free(looked_up_ref); cl_git_fail(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name)); git_reference_free(ref); git_reference_free(ref_two); git_reference_free(looked_up_ref); } void test_refs_rename__move_up(void) { /* can move a reference to a upper reference hierarchy */ git_reference *ref, *ref_two, *looked_up_ref, *renamed_ref; git_oid id; cl_git_pass(git_reference_lookup(&ref, g_repo, ref_master_name)); cl_assert(git_reference_type(ref) & GIT_REFERENCE_DIRECT); git_oid_cpy(&id, git_reference_target(ref)); /* Create loose references */ cl_git_pass(git_reference_create(&ref_two, g_repo, ref_two_name_new, &id, 0, NULL)); git_reference_free(ref_two); /* An existing reference... */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name_new)); /* Can be renamed upward the reference tree. */ cl_git_pass(git_reference_rename(&renamed_ref, looked_up_ref, ref_two_name, 0, NULL)); git_reference_free(looked_up_ref); git_reference_free(renamed_ref); /* Check we actually renamed it */ cl_git_pass(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name)); cl_assert_equal_s(looked_up_ref->name, ref_two_name); git_reference_free(looked_up_ref); cl_git_fail(git_reference_lookup(&looked_up_ref, g_repo, ref_two_name_new)); git_reference_free(ref); git_reference_free(looked_up_ref); } void test_refs_rename__propagate_eexists(void) { git_reference *ref, *new_ref; cl_git_pass(git_reference_lookup(&ref, g_repo, packed_head_name)); cl_assert_equal_i(GIT_EEXISTS, git_reference_rename(&new_ref, ref, packed_test_head_name, 0, NULL)); git_reference_free(ref); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/list.c
#include "clar_libgit2.h" #include "repository.h" #include "git2/reflog.h" #include "reflog.h" static git_repository *g_repo; void test_refs_list__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); } void test_refs_list__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_list__all(void) { /* try to list all the references in our test repo */ git_strarray ref_list; cl_git_pass(git_reference_list(&ref_list, g_repo)); /*{ unsigned short i; for (i = 0; i < ref_list.count; ++i) printf("# %s\n", ref_list.strings[i]); }*/ /* We have exactly 12 refs in total if we include the packed ones: * there is a reference that exists both in the packfile and as * loose, but we only list it once */ cl_assert_equal_i((int)ref_list.count, 19); git_strarray_dispose(&ref_list); } void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_extension(void) { git_strarray ref_list; /* Create a fake locked reference */ cl_git_mkfile( "./testrepo/.git/refs/heads/hanwen.lock", "144344043ba4d4a405da03de3844aa829ae8be0e\n"); cl_git_pass(git_reference_list(&ref_list, g_repo)); cl_assert_equal_i((int)ref_list.count, 19); git_strarray_dispose(&ref_list); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/branches/create.c
#include "clar_libgit2.h" #include "refs.h" #include "path.h" static git_repository *repo; static git_commit *target; static git_reference *branch; void test_refs_branches_create__initialize(void) { repo = cl_git_sandbox_init("testrepo.git"); branch = NULL; target = NULL; } void test_refs_branches_create__cleanup(void) { git_reference_free(branch); branch = NULL; git_commit_free(target); target = NULL; cl_git_sandbox_cleanup(); repo = NULL; } static void retrieve_target_from_oid(git_commit **out, git_repository *repo, const char *sha) { git_object *obj; cl_git_pass(git_revparse_single(&obj, repo, sha)); cl_git_pass(git_commit_lookup(out, repo, git_object_id(obj))); git_object_free(obj); } static void retrieve_known_commit(git_commit **commit, git_repository *repo) { retrieve_target_from_oid(commit, repo, "e90810b8df3"); } #define NEW_BRANCH_NAME "new-branch-on-the-block" void test_refs_branches_create__can_create_a_local_branch(void) { retrieve_known_commit(&target, repo); cl_git_pass(git_branch_create(&branch, repo, NEW_BRANCH_NAME, target, 0)); cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target))); } void test_refs_branches_create__can_not_create_a_branch_if_its_name_collide_with_an_existing_one(void) { retrieve_known_commit(&target, repo); cl_assert_equal_i(GIT_EEXISTS, git_branch_create(&branch, repo, "br2", target, 0)); } void test_refs_branches_create__can_force_create_over_an_existing_branch(void) { retrieve_known_commit(&target, repo); cl_git_pass(git_branch_create(&branch, repo, "br2", target, 1)); cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target))); cl_assert_equal_s("refs/heads/br2", git_reference_name(branch)); } void test_refs_branches_create__cannot_force_create_over_current_branch_in_nonbare_repo(void) { const git_oid *oid; git_reference *branch2; /* Default repo for these tests is a bare repo, but this test requires a non-bare one */ cl_git_sandbox_cleanup(); repo = cl_git_sandbox_init("testrepo"); retrieve_known_commit(&target, repo); cl_git_pass(git_branch_lookup(&branch2, repo, "master", GIT_BRANCH_LOCAL)); cl_assert_equal_s("refs/heads/master", git_reference_name(branch2)); cl_assert_equal_i(true, git_branch_is_head(branch2)); oid = git_reference_target(branch2); cl_git_fail_with(-1, git_branch_create(&branch, repo, "master", target, 1)); branch = NULL; cl_git_pass(git_branch_lookup(&branch, repo, "master", GIT_BRANCH_LOCAL)); cl_assert_equal_s("refs/heads/master", git_reference_name(branch)); cl_git_pass(git_oid_cmp(git_reference_target(branch), oid)); git_reference_free(branch2); } void test_refs_branches_create__can_force_create_over_current_branch_in_bare_repo(void) { const git_oid *oid; git_reference *branch2; retrieve_known_commit(&target, repo); cl_git_pass(git_branch_lookup(&branch2, repo, "master", GIT_BRANCH_LOCAL)); cl_assert_equal_s("refs/heads/master", git_reference_name(branch2)); cl_assert_equal_i(true, git_branch_is_head(branch2)); oid = git_commit_id(target); cl_git_pass(git_branch_create(&branch, repo, "master", target, 1)); git_reference_free(branch); branch = NULL; cl_git_pass(git_branch_lookup(&branch, repo, "master", GIT_BRANCH_LOCAL)); cl_assert_equal_s("refs/heads/master", git_reference_name(branch)); cl_git_pass(git_oid_cmp(git_reference_target(branch), oid)); git_reference_free(branch2); } void test_refs_branches_create__creating_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void) { retrieve_known_commit(&target, repo); cl_assert_equal_i(GIT_EINVALIDSPEC, git_branch_create(&branch, repo, "inv@{id", target, 0)); } static void assert_branch_matches_name( const char *expected, const char *lookup_as) { git_reference *ref; git_buf b = GIT_BUF_INIT; cl_git_pass(git_branch_lookup(&ref, repo, lookup_as, GIT_BRANCH_LOCAL)); cl_git_pass(git_buf_sets(&b, "refs/heads/")); cl_git_pass(git_buf_puts(&b, expected)); cl_assert_equal_s(b.ptr, git_reference_name(ref)); cl_git_pass( git_oid_cmp(git_reference_target(ref), git_commit_id(target))); git_reference_free(ref); git_buf_dispose(&b); } void test_refs_branches_create__can_create_branch_with_unicode(void) { const char *nfc = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D"; const char *nfd = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D"; const char *emoji = "\xF0\x9F\x8D\xB7"; const char *names[] = { nfc, nfd, emoji }; const char *alt[] = { nfd, nfc, NULL }; const char *expected[] = { nfc, nfd, emoji }; unsigned int i; bool fs_decompose_unicode = git_path_does_fs_decompose_unicode(git_repository_path(repo)); retrieve_known_commit(&target, repo); if (cl_repo_get_bool(repo, "core.precomposeunicode")) expected[1] = nfc; /* test decomp. because not all Mac filesystems decompose unicode */ else if (fs_decompose_unicode) expected[0] = nfd; for (i = 0; i < ARRAY_SIZE(names); ++i) { const char *name; cl_git_pass(git_branch_create( &branch, repo, names[i], target, 0)); cl_git_pass(git_oid_cmp( git_reference_target(branch), git_commit_id(target))); cl_git_pass(git_branch_name(&name, branch)); cl_assert_equal_s(expected[i], name); assert_branch_matches_name(expected[i], names[i]); if (fs_decompose_unicode && alt[i]) assert_branch_matches_name(expected[i], alt[i]); cl_git_pass(git_branch_delete(branch)); git_reference_free(branch); branch = NULL; } } /** * Verify that we can create a branch with a name that matches the * namespace of a previously delete branch. * * git branch level_one/level_two * git branch -D level_one/level_two * git branch level_one * * We expect the delete to have deleted the files: * ".git/refs/heads/level_one/level_two" * ".git/logs/refs/heads/level_one/level_two" * It may or may not have deleted the (now empty) * containing directories. To match git.git behavior, * the second create needs to implicilty delete the * directories and create the new files. * "refs/heads/level_one" * "logs/refs/heads/level_one" * * We should not fail to create the branch or its * reflog because of an obsolete namespace container * directory. */ void test_refs_branches_create__name_vs_namespace(void) { const char * name; struct item { const char *first; const char *second; }; static const struct item item[] = { { "level_one/level_two", "level_one" }, { "a/b/c/d/e", "a/b/c/d" }, { "ss/tt/uu/vv/ww", "ss" }, /* And one test case that is deeper. */ { "xx1/xx2/xx3/xx4", "xx1/xx2/xx3/xx4/xx5/xx6" }, { NULL, NULL }, }; const struct item *p; retrieve_known_commit(&target, repo); for (p=item; p->first; p++) { cl_git_pass(git_branch_create(&branch, repo, p->first, target, 0)); cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target))); cl_git_pass(git_branch_name(&name, branch)); cl_assert_equal_s(name, p->first); cl_git_pass(git_branch_delete(branch)); git_reference_free(branch); branch = NULL; cl_git_pass(git_branch_create(&branch, repo, p->second, target, 0)); git_reference_free(branch); branch = NULL; } } /** * We still need to fail if part of the namespace is * still in use. */ void test_refs_branches_create__name_vs_namespace_fail(void) { const char * name; struct item { const char *first; const char *first_alternate; const char *second; }; static const struct item item[] = { { "level_one/level_two", "level_one/alternate", "level_one" }, { "a/b/c/d/e", "a/b/c/d/alternate", "a/b/c/d" }, { "ss/tt/uu/vv/ww", "ss/alternate", "ss" }, { NULL, NULL, NULL }, }; const struct item *p; retrieve_known_commit(&target, repo); for (p=item; p->first; p++) { cl_git_pass(git_branch_create(&branch, repo, p->first, target, 0)); cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target))); cl_git_pass(git_branch_name(&name, branch)); cl_assert_equal_s(name, p->first); cl_git_pass(git_branch_delete(branch)); git_reference_free(branch); branch = NULL; cl_git_pass(git_branch_create(&branch, repo, p->first_alternate, target, 0)); cl_git_pass(git_oid_cmp(git_reference_target(branch), git_commit_id(target))); cl_git_pass(git_branch_name(&name, branch)); cl_assert_equal_s(name, p->first_alternate); /* we do not delete the alternate. */ git_reference_free(branch); branch = NULL; cl_git_fail(git_branch_create(&branch, repo, p->second, target, 0)); git_reference_free(branch); branch = NULL; } }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/branches/remote.c
#include "clar_libgit2.h" #include "branch.h" #include "remote.h" static git_repository *g_repo; static const char *remote_tracking_branch_name = "refs/remotes/test/master"; static const char *expected_remote_name = "test"; static int expected_remote_name_length; void test_refs_branches_remote__initialize(void) { g_repo = cl_git_sandbox_init("testrepo"); expected_remote_name_length = (int)strlen(expected_remote_name) + 1; } void test_refs_branches_remote__cleanup(void) { cl_git_sandbox_cleanup(); } void test_refs_branches_remote__can_get_remote_for_branch(void) { git_buf remotename = {0}; cl_git_pass(git_branch_remote_name(&remotename, g_repo, remote_tracking_branch_name)); cl_assert_equal_s("test", remotename.ptr); git_buf_dispose(&remotename); } void test_refs_branches_remote__no_matching_remote_returns_error(void) { const char *unknown = "refs/remotes/nonexistent/master"; git_buf buf; git_error_clear(); memset(&buf, 0, sizeof(git_buf)); cl_git_fail_with(git_branch_remote_name(&buf, g_repo, unknown), GIT_ENOTFOUND); cl_assert(git_error_last() != NULL); } void test_refs_branches_remote__local_remote_returns_error(void) { const char *local = "refs/heads/master"; git_buf buf; git_error_clear(); memset(&buf, 0, sizeof(git_buf)); cl_git_fail_with(git_branch_remote_name(&buf, g_repo, local), GIT_ERROR); cl_assert(git_error_last() != NULL); } void test_refs_branches_remote__ambiguous_remote_returns_error(void) { git_remote *remote; git_buf buf; /* Create the remote */ cl_git_pass(git_remote_create_with_fetchspec(&remote, g_repo, "addtest", "http://github.com/libgit2/libgit2", "refs/heads/*:refs/remotes/test/*")); git_remote_free(remote); git_error_clear(); memset(&buf, 0, sizeof(git_buf)); cl_git_fail_with(git_branch_remote_name(&buf, g_repo, remote_tracking_branch_name), GIT_EAMBIGUOUS); cl_assert(git_error_last() != NULL); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/branches/name.c
#include "clar_libgit2.h" #include "branch.h" static git_repository *repo; static git_reference *ref; void test_refs_branches_name__initialize(void) { cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git"))); } void test_refs_branches_name__cleanup(void) { git_reference_free(ref); ref = NULL; git_repository_free(repo); repo = NULL; } void test_refs_branches_name__can_get_local_branch_name(void) { const char *name; cl_git_pass(git_branch_lookup(&ref,repo,"master",GIT_BRANCH_LOCAL)); cl_git_pass(git_branch_name(&name,ref)); cl_assert_equal_s("master",name); } void test_refs_branches_name__can_get_remote_branch_name(void) { const char *name; cl_git_pass(git_branch_lookup(&ref,repo,"test/master",GIT_BRANCH_REMOTE)); cl_git_pass(git_branch_name(&name,ref)); cl_assert_equal_s("test/master",name); } void test_refs_branches_name__error_when_ref_is_no_branch(void) { const char *name; cl_git_pass(git_reference_lookup(&ref,repo,"refs/notes/fanout")); cl_git_fail(git_branch_name(&name,ref)); } static int name_is_valid(const char *name) { int valid; cl_git_pass(git_branch_name_is_valid(&valid, name)); return valid; } void test_refs_branches_is_name_valid(void) { cl_assert_equal_i(true, name_is_valid("master")); cl_assert_equal_i(true, name_is_valid("test/master")); cl_assert_equal_i(false, name_is_valid("")); cl_assert_equal_i(false, name_is_valid("HEAD")); cl_assert_equal_i(false, name_is_valid("-dash")); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/branches/move.c
#include "clar_libgit2.h" #include "refs.h" #include "config/config_helpers.h" static git_repository *repo; void test_refs_branches_move__initialize(void) { repo = cl_git_sandbox_init("testrepo.git"); } void test_refs_branches_move__cleanup(void) { cl_git_sandbox_cleanup(); } #define NEW_BRANCH_NAME "new-branch-on-the-block" void test_refs_branches_move__can_move_a_local_branch(void) { git_reference *original_ref, *new_ref; cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_git_pass(git_branch_move(&new_ref, original_ref, NEW_BRANCH_NAME, 0)); cl_assert_equal_s(GIT_REFS_HEADS_DIR NEW_BRANCH_NAME, git_reference_name(new_ref)); git_reference_free(original_ref); git_reference_free(new_ref); } void test_refs_branches_move__can_move_a_local_branch_to_a_different_namespace(void) { git_reference *original_ref, *new_ref, *newer_ref; cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); /* Downward */ cl_git_pass(git_branch_move(&new_ref, original_ref, "somewhere/" NEW_BRANCH_NAME, 0)); git_reference_free(original_ref); /* Upward */ cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0)); git_reference_free(new_ref); git_reference_free(newer_ref); } void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_namespace(void) { git_reference *original_ref, *new_ref, *newer_ref; cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); /* Downward */ cl_git_pass(git_branch_move(&new_ref, original_ref, "br2/" NEW_BRANCH_NAME, 0)); git_reference_free(original_ref); /* Upward */ cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0)); git_reference_free(new_ref); git_reference_free(newer_ref); } void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_collide_with_an_existing_one(void) { git_reference *original_ref, *new_ref; git_config *config; git_buf buf = GIT_BUF_INIT; char *original_remote, *original_merge; const char *str; cl_git_pass(git_repository_config_snapshot(&config, repo)); cl_git_pass(git_config_get_string_buf(&buf, config, "branch.master.remote")); original_remote = git_buf_detach(&buf); cl_git_pass(git_config_get_string_buf(&buf, config, "branch.master.merge")); original_merge = git_buf_detach(&buf); git_config_free(config); cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_assert_equal_i(GIT_EEXISTS, git_branch_move(&new_ref, original_ref, "master", 0)); cl_assert(git_error_last()->message != NULL); cl_git_pass(git_repository_config_snapshot(&config, repo)); cl_git_pass(git_config_get_string(&str, config, "branch.master.remote")); cl_assert_equal_s(original_remote, str); cl_git_pass(git_config_get_string(&str, config, "branch.master.merge")); cl_assert_equal_s(original_merge, str); git_config_free(config); cl_assert_equal_i(GIT_EEXISTS, git_branch_move(&new_ref, original_ref, "cannot-fetch", 0)); cl_assert(git_error_last()->message != NULL); cl_git_pass(git_repository_config_snapshot(&config, repo)); cl_git_pass(git_config_get_string(&str, config, "branch.master.remote")); cl_assert_equal_s(original_remote, str); cl_git_pass(git_config_get_string(&str, config, "branch.master.merge")); cl_assert_equal_s(original_merge, str); git_config_free(config); git_reference_free(original_ref); cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/track-local")); cl_assert_equal_i(GIT_EEXISTS, git_branch_move(&new_ref, original_ref, "master", 0)); cl_assert(git_error_last()->message != NULL); cl_git_pass(git_repository_config_snapshot(&config, repo)); cl_git_pass(git_config_get_string(&str, config, "branch.master.remote")); cl_assert_equal_s(original_remote, str); cl_git_pass(git_config_get_string(&str, config, "branch.master.merge")); cl_assert_equal_s(original_merge, str); git__free(original_remote); git__free(original_merge); git_reference_free(original_ref); git_config_free(config); } void test_refs_branches_move__moving_a_branch_with_an_invalid_name_returns_EINVALIDSPEC(void) { git_reference *original_ref, *new_ref; cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_assert_equal_i(GIT_EINVALIDSPEC, git_branch_move(&new_ref, original_ref, "Inv@{id", 0)); git_reference_free(original_ref); } void test_refs_branches_move__can_not_move_a_non_branch(void) { git_reference *tag, *new_ref; cl_git_pass(git_reference_lookup(&tag, repo, "refs/tags/e90810b")); cl_git_fail(git_branch_move(&new_ref, tag, NEW_BRANCH_NAME, 0)); git_reference_free(tag); } void test_refs_branches_move__can_force_move_over_an_existing_branch(void) { git_reference *original_ref, *new_ref; cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_git_pass(git_branch_move(&new_ref, original_ref, "master", 1)); git_reference_free(original_ref); git_reference_free(new_ref); } void test_refs_branches_move__moving_a_branch_moves_related_configuration_data(void) { git_reference *branch; git_reference *new_branch; cl_git_pass(git_branch_lookup(&branch, repo, "track-local", GIT_BRANCH_LOCAL)); assert_config_entry_existence(repo, "branch.track-local.remote", true); assert_config_entry_existence(repo, "branch.track-local.merge", true); assert_config_entry_existence(repo, "branch.moved.remote", false); assert_config_entry_existence(repo, "branch.moved.merge", false); cl_git_pass(git_branch_move(&new_branch, branch, "moved", 0)); git_reference_free(branch); assert_config_entry_existence(repo, "branch.track-local.remote", false); assert_config_entry_existence(repo, "branch.track-local.merge", false); assert_config_entry_existence(repo, "branch.moved.remote", true); assert_config_entry_existence(repo, "branch.moved.merge", true); git_reference_free(new_branch); } void test_refs_branches_move__moving_the_branch_pointed_at_by_HEAD_updates_HEAD(void) { git_reference *branch; git_reference *new_branch; cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master")); cl_git_pass(git_branch_move(&new_branch, branch, "master2", 0)); git_reference_free(branch); git_reference_free(new_branch); cl_git_pass(git_repository_head(&branch, repo)); cl_assert_equal_s("refs/heads/master2", git_reference_name(branch)); git_reference_free(branch); } void test_refs_branches_move__can_move_with_unicode(void) { git_reference *original_ref, *new_ref; const char *new_branch_name = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D"; cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_git_pass(git_branch_move(&new_ref, original_ref, new_branch_name, 0)); if (cl_repo_get_bool(repo, "core.precomposeunicode")) cl_assert_equal_s(GIT_REFS_HEADS_DIR "\xC3\x85\x73\x74\x72\xC3\xB6\x6D", git_reference_name(new_ref)); else cl_assert_equal_s(GIT_REFS_HEADS_DIR "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D", git_reference_name(new_ref)); git_reference_free(original_ref); git_reference_free(new_ref); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/branches/delete.c
#include "clar_libgit2.h" #include "refs.h" #include "repo/repo_helpers.h" #include "config/config_helpers.h" #include "futils.h" #include "reflog.h" static git_repository *repo; static git_reference *fake_remote; void test_refs_branches_delete__initialize(void) { git_oid id; repo = cl_git_sandbox_init("testrepo.git"); cl_git_pass(git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644")); cl_git_pass(git_reference_create(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0, NULL)); } void test_refs_branches_delete__cleanup(void) { git_reference_free(fake_remote); fake_remote = NULL; cl_git_sandbox_cleanup(); repo = NULL; } void test_refs_branches_delete__can_not_delete_a_branch_pointed_at_by_HEAD(void) { git_reference *head; git_reference *branch; /* Ensure HEAD targets the local master branch */ cl_git_pass(git_reference_lookup(&head, repo, GIT_HEAD_FILE)); cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head)); git_reference_free(head); cl_git_pass(git_branch_lookup(&branch, repo, "master", GIT_BRANCH_LOCAL)); cl_git_fail(git_branch_delete(branch)); git_reference_free(branch); } void test_refs_branches_delete__can_delete_a_branch_even_if_HEAD_is_missing(void) { git_reference *head; git_reference *branch; cl_git_pass(git_reference_lookup(&head, repo, GIT_HEAD_FILE)); git_reference_delete(head); git_reference_free(head); cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_LOCAL)); cl_git_pass(git_branch_delete(branch)); git_reference_free(branch); } void test_refs_branches_delete__can_delete_a_branch_when_HEAD_is_unborn(void) { git_reference *branch; make_head_unborn(repo, NON_EXISTING_HEAD); cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_LOCAL)); cl_git_pass(git_branch_delete(branch)); git_reference_free(branch); } void test_refs_branches_delete__can_delete_a_branch_pointed_at_by_detached_HEAD(void) { git_reference *head, *branch; cl_git_pass(git_reference_lookup(&head, repo, GIT_HEAD_FILE)); cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(head)); cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head)); git_reference_free(head); /* Detach HEAD and make it target the commit that "master" points to */ git_repository_detach_head(repo); cl_git_pass(git_branch_lookup(&branch, repo, "master", GIT_BRANCH_LOCAL)); cl_git_pass(git_branch_delete(branch)); git_reference_free(branch); } void test_refs_branches_delete__can_delete_a_local_branch(void) { git_reference *branch; cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_LOCAL)); cl_git_pass(git_branch_delete(branch)); git_reference_free(branch); } void test_refs_branches_delete__can_delete_a_remote_branch(void) { git_reference *branch; cl_git_pass(git_branch_lookup(&branch, repo, "nulltoken/master", GIT_BRANCH_REMOTE)); cl_git_pass(git_branch_delete(branch)); git_reference_free(branch); } void test_refs_branches_delete__deleting_a_branch_removes_related_configuration_data(void) { git_reference *branch; assert_config_entry_existence(repo, "branch.track-local.remote", true); assert_config_entry_existence(repo, "branch.track-local.merge", true); cl_git_pass(git_branch_lookup(&branch, repo, "track-local", GIT_BRANCH_LOCAL)); cl_git_pass(git_branch_delete(branch)); git_reference_free(branch); assert_config_entry_existence(repo, "branch.track-local.remote", false); assert_config_entry_existence(repo, "branch.track-local.merge", false); } void test_refs_branches_delete__removes_reflog(void) { git_reference *branch; git_reflog *log; git_oid oidzero = {{0}}; git_signature *sig; /* Ensure the reflog has at least one entry */ cl_git_pass(git_signature_now(&sig, "Me", "[email protected]")); cl_git_pass(git_reflog_read(&log, repo, "refs/heads/track-local")); cl_git_pass(git_reflog_append(log, &oidzero, sig, "message")); cl_assert(git_reflog_entrycount(log) > 0); git_signature_free(sig); git_reflog_free(log); cl_git_pass(git_branch_lookup(&branch, repo, "track-local", GIT_BRANCH_LOCAL)); cl_git_pass(git_branch_delete(branch)); git_reference_free(branch); cl_assert_equal_i(false, git_reference_has_log(repo, "refs/heads/track-local")); /* Reading a nonexistant reflog creates it, but it should be empty */ cl_git_pass(git_reflog_read(&log, repo, "refs/heads/track-local")); cl_assert_equal_i(0, git_reflog_entrycount(log)); git_reflog_free(log); } void test_refs_branches_delete__removes_empty_folders(void) { const char *commondir = git_repository_commondir(repo); git_oid commit_id; git_commit *commit; git_reference *branch; git_reflog *log; git_oid oidzero = {{0}}; git_signature *sig; git_buf ref_folder = GIT_BUF_INIT; git_buf reflog_folder = GIT_BUF_INIT; /* Create a new branch with a nested name */ cl_git_pass(git_oid_fromstr(&commit_id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750")); cl_git_pass(git_commit_lookup(&commit, repo, &commit_id)); cl_git_pass(git_branch_create(&branch, repo, "some/deep/ref", commit, 0)); git_commit_free(commit); /* Ensure the reflog has at least one entry */ cl_git_pass(git_signature_now(&sig, "Me", "[email protected]")); cl_git_pass(git_reflog_read(&log, repo, "refs/heads/some/deep/ref")); cl_git_pass(git_reflog_append(log, &oidzero, sig, "message")); cl_assert(git_reflog_entrycount(log) > 0); git_signature_free(sig); git_reflog_free(log); cl_git_pass(git_buf_joinpath(&ref_folder, commondir, "refs/heads/some/deep")); cl_git_pass(git_buf_join3(&reflog_folder, '/', commondir, GIT_REFLOG_DIR, "refs/heads/some/deep")); cl_assert(git_path_exists(git_buf_cstr(&ref_folder)) == true); cl_assert(git_path_exists(git_buf_cstr(&reflog_folder)) == true); cl_git_pass(git_branch_delete(branch)); cl_assert(git_path_exists(git_buf_cstr(&ref_folder)) == false); cl_assert(git_path_exists(git_buf_cstr(&reflog_folder)) == false); git_reference_free(branch); git_buf_dispose(&ref_folder); git_buf_dispose(&reflog_folder); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/branches/checkedout.c
#include "clar_libgit2.h" #include "refs.h" #include "worktree/worktree_helpers.h" static git_repository *repo; static void assert_checked_out(git_repository *repo, const char *branch, int checked_out) { git_reference *ref; cl_git_pass(git_reference_lookup(&ref, repo, branch)); cl_assert(git_branch_is_checked_out(ref) == checked_out); git_reference_free(ref); } void test_refs_branches_checkedout__simple_repo(void) { repo = cl_git_sandbox_init("testrepo"); assert_checked_out(repo, "refs/heads/master", 1); assert_checked_out(repo, "refs/heads/executable", 0); cl_git_sandbox_cleanup(); } void test_refs_branches_checkedout__worktree(void) { static worktree_fixture fixture = WORKTREE_FIXTURE_INIT("testrepo", "testrepo-worktree"); setup_fixture_worktree(&fixture); assert_checked_out(fixture.repo, "refs/heads/master", 1); assert_checked_out(fixture.repo, "refs/heads/testrepo-worktree", 1); assert_checked_out(fixture.worktree, "refs/heads/master", 1); assert_checked_out(fixture.worktree, "refs/heads/testrepo-worktree", 1); cleanup_fixture_worktree(&fixture); } void test_refs_branches_checkedout__head_is_not_checked_out(void) { repo = cl_git_sandbox_init("testrepo"); assert_checked_out(repo, "HEAD", 0); cl_git_sandbox_cleanup(); } void test_refs_branches_checkedout__master_in_bare_repo_is_not_checked_out(void) { repo = cl_git_sandbox_init("testrepo.git"); assert_checked_out(repo, "refs/heads/master", 0); cl_git_sandbox_cleanup(); }
0
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs
repos/gyro/.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2/tests/refs/branches/upstreamname.c
#include "clar_libgit2.h" #include "branch.h" static git_repository *repo; static git_buf upstream_name; void test_refs_branches_upstreamname__initialize(void) { cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git"))); git_buf_init(&upstream_name, 0); } void test_refs_branches_upstreamname__cleanup(void) { git_buf_dispose(&upstream_name); git_repository_free(repo); repo = NULL; } void test_refs_branches_upstreamname__can_retrieve_the_remote_tracking_reference_name_of_a_local_branch(void) { cl_git_pass(git_branch_upstream_name( &upstream_name, repo, "refs/heads/master")); cl_assert_equal_s("refs/remotes/test/master", git_buf_cstr(&upstream_name)); } void test_refs_branches_upstreamname__can_retrieve_the_local_upstream_reference_name_of_a_local_branch(void) { cl_git_pass(git_branch_upstream_name( &upstream_name, repo, "refs/heads/track-local")); cl_assert_equal_s("refs/heads/master", git_buf_cstr(&upstream_name)); }