mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 11:06:32 +00:00
Merge pull request #4151 from novalis/dturner/rebase-submodule-untracked
rebase: ignore untracked files in submodules
This commit is contained in:
@@ -546,7 +546,9 @@ static int rebase_ensure_not_dirty(
|
||||
}
|
||||
|
||||
if (check_workdir) {
|
||||
if ((error = git_diff_index_to_workdir(&diff, repo, index, NULL)) < 0)
|
||||
git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT;
|
||||
diff_opts.ignore_submodules = GIT_SUBMODULE_IGNORE_UNTRACKED;
|
||||
if ((error = git_diff_index_to_workdir(&diff, repo, index, &diff_opts)) < 0)
|
||||
goto done;
|
||||
|
||||
if (git_diff_num_deltas(diff) > 0) {
|
||||
|
||||
65
tests/rebase/submodule.c
Normal file
65
tests/rebase/submodule.c
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "clar_libgit2.h"
|
||||
#include "git2/checkout.h"
|
||||
#include "git2/rebase.h"
|
||||
#include "posix.h"
|
||||
#include "signature.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
static git_repository *repo;
|
||||
static git_signature *signature;
|
||||
|
||||
// Fixture setup and teardown
|
||||
void test_rebase_submodule__initialize(void)
|
||||
{
|
||||
repo = cl_git_sandbox_init("rebase-submodule");
|
||||
cl_git_pass(git_signature_new(&signature,
|
||||
"Rebaser", "rebaser@rebaser.rb", 1405694510, 0));
|
||||
}
|
||||
|
||||
void test_rebase_submodule__cleanup(void)
|
||||
{
|
||||
git_signature_free(signature);
|
||||
cl_git_sandbox_cleanup();
|
||||
}
|
||||
|
||||
void test_rebase_submodule__init_untracked(void)
|
||||
{
|
||||
git_rebase *rebase;
|
||||
git_reference *branch_ref, *upstream_ref;
|
||||
git_annotated_commit *branch_head, *upstream_head;
|
||||
git_buf untracked_path = GIT_BUF_INIT;
|
||||
FILE *fp;
|
||||
git_submodule *submodule;
|
||||
git_config *config;
|
||||
|
||||
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/asparagus"));
|
||||
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
|
||||
|
||||
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
|
||||
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
|
||||
|
||||
git_repository_config(&config, repo);
|
||||
|
||||
cl_git_pass(git_config_set_string(config, "submodule.my-submodule.url", git_repository_path(repo)));
|
||||
|
||||
git_config_free(config);
|
||||
|
||||
cl_git_pass(git_submodule_lookup(&submodule, repo, "my-submodule"));
|
||||
cl_git_pass(git_submodule_update(submodule, 1, NULL));
|
||||
|
||||
git_buf_printf(&untracked_path, "%s/my-submodule/untracked", git_repository_workdir(repo));
|
||||
fp = fopen(git_buf_cstr(&untracked_path), "w");
|
||||
fprintf(fp, "An untracked file in a submodule should not block a rebase\n");
|
||||
fclose(fp);
|
||||
git_buf_free(&untracked_path);
|
||||
|
||||
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));
|
||||
|
||||
git_submodule_free(submodule);
|
||||
git_annotated_commit_free(branch_head);
|
||||
git_annotated_commit_free(upstream_head);
|
||||
git_reference_free(branch_ref);
|
||||
git_reference_free(upstream_ref);
|
||||
git_rebase_free(rebase);
|
||||
}
|
||||
3
tests/resources/rebase-submodule/.gitmodules
vendored
Normal file
3
tests/resources/rebase-submodule/.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "my-submodule"]
|
||||
path = my-submodule
|
||||
url = bogus
|
||||
1
tests/resources/rebase-submodule/.gitted/HEAD
Normal file
1
tests/resources/rebase-submodule/.gitted/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
||||
1
tests/resources/rebase-submodule/.gitted/ORIG_HEAD
Normal file
1
tests/resources/rebase-submodule/.gitted/ORIG_HEAD
Normal file
@@ -0,0 +1 @@
|
||||
5fdf086684daae0a8bc61a81afe178edc1e556e7
|
||||
9
tests/resources/rebase-submodule/.gitted/config
Normal file
9
tests/resources/rebase-submodule/.gitted/config
Normal file
@@ -0,0 +1,9 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
[branch "asparagus"]
|
||||
rebase = true
|
||||
[branch "master"]
|
||||
rebase = true
|
||||
1
tests/resources/rebase-submodule/.gitted/description
Normal file
1
tests/resources/rebase-submodule/.gitted/description
Normal file
@@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
||||
BIN
tests/resources/rebase-submodule/.gitted/index
Normal file
BIN
tests/resources/rebase-submodule/.gitted/index
Normal file
Binary file not shown.
6
tests/resources/rebase-submodule/.gitted/info/exclude
Normal file
6
tests/resources/rebase-submodule/.gitted/info/exclude
Normal file
@@ -0,0 +1,6 @@
|
||||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
||||
4
tests/resources/rebase-submodule/.gitted/info/refs
Normal file
4
tests/resources/rebase-submodule/.gitted/info/refs
Normal file
@@ -0,0 +1,4 @@
|
||||
c64ea52df5b31efd7b73769418dc9e25b8803d25 refs/heads/asparagus
|
||||
c64ea52df5b31efd7b73769418dc9e25b8803d25 refs/remotes/origin/HEAD
|
||||
c64ea52df5b31efd7b73769418dc9e25b8803d25 refs/remotes/origin/asparagus
|
||||
02a35db3f24db554b757b3009bc782784267c743 refs/remotes/origin/master
|
||||
@@ -0,0 +1 @@
|
||||
xUÎAjÃ0Юuй@ÂX–fd%<25>¡<17>4Rjˆ¬"ËÉõë–tÑÕ|>ÿÁÄZÊÜA<C39C>ã[o)G2R<>1ä <20>qbthçˆ&BÔ—oié?û<><C3BB>M»<Èà"Z¢Ì¨EÇÀL¦èÄdå·þY\ýcøØÚ’œ¤ÿ†sÖu¾Œµ¼Ã`œ³dˆhÕÞîOö]üçK}øû¼ž_÷XÛíO;Ãú¥ÕE<¬[(U¶{Rß1ØJ<C398>
|
||||
@@ -0,0 +1 @@
|
||||
x-<2D>KnÃ0D»Ö)x<>Mý€ È¢Yv×P'j«<6A>åôú•‹¬ÈâqÈX—¥t@=½õ–3p0qF<14>e´ÄìÒ¤‚vÖ&<26>©ì"²<>â‡[^;HåÊHzb’6Sð³‰ÎèŒq²3¥€*1z¼÷GmpK¿Ü|=ê²Õ.y¸GwÍÿƒ—:Ǻ¼ƒ"©
*CN’¤ÃÇöÜàƒŸelÙÛ:ÄeOþ.ÛõUϵÝÚ9m¹ƒÖƒŸ5•¹Dîe$+èxoð}ßIJÑRC
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
x¥<>±NÄ0D©ý««ádç'‘‚ úýÆÞ\Vн‘í\~Ÿ€øº™÷¤/1r…¦w5<13>m|À0èÒt¡ntƺ®%×öû‘¬ékcnu–ïaÇà:K,’à™ú“^éWüµ³—øÆêÖ5¦í5<i«µ:èq^éŸ3ê3qe\ Ó<>KRê
&ڡȶÐóJ¦,N×™à‹ó<E280B9>#|ÈVhç‰N<E280B0>€wäÇ…€Ô™Ôº<C394>{‘ÓY}RYa)
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
x%P1nÄ0ëìWð¹C<C2B9>NE§N7¶è¡:*‰’p¬Ô’/¸ßWÎmI‘”ú$=^^ŸŸ._ï?¿¸~|žC¸°<C2B8>ã¼6©yTÈ„A¨(#1eôÌÓé´“.ˆ†áÀ(<28>Hto@̸K-aë°Õ°…¡´²“sá1r6)&)8¸Å·TêÖa<C396>¶<0ׇ¿JÙ¢Ý[‡<>ŒK‡5IJ²²ÈÀªcáÁ¸q͓쌫r_ÍÛ‡"u^@ÐÈ7~X)—›÷2¸ Ýâ G…,æ¥f¬R¸ùå`BÚúÂ4¶3£½Áv<C381>QŸø¤›HÖ©¦Öuêa²b SwÞcJ q…)fÆ”èæO‚ùvû<76>×;‡í«ŒŸ
|
||||
Binary file not shown.
Binary file not shown.
2
tests/resources/rebase-submodule/.gitted/packed-refs
Normal file
2
tests/resources/rebase-submodule/.gitted/packed-refs
Normal file
@@ -0,0 +1,2 @@
|
||||
# pack-refs with: peeled fully-peeled
|
||||
c64ea52df5b31efd7b73769418dc9e25b8803d25 refs/heads/asparagus
|
||||
@@ -0,0 +1 @@
|
||||
17f8ae8ebdd08a4bb272f61b897b308ad42b1b12
|
||||
@@ -0,0 +1 @@
|
||||
01971e2453a407e4b9f6c865e2c37f4db21da294
|
||||
10
tests/resources/rebase-submodule/asparagus.txt
Normal file
10
tests/resources/rebase-submodule/asparagus.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
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.
|
||||
22
tests/resources/rebase-submodule/beef.txt
Normal file
22
tests/resources/rebase-submodule/beef.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
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.
|
||||
18
tests/resources/rebase-submodule/bouilli.txt
Normal file
18
tests/resources/rebase-submodule/bouilli.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
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.
|
||||
8
tests/resources/rebase-submodule/gravy.txt
Normal file
8
tests/resources/rebase-submodule/gravy.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
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.
|
||||
1
tests/resources/rebase-submodule/my-submodule
Submodule
1
tests/resources/rebase-submodule/my-submodule
Submodule
Submodule tests/resources/rebase-submodule/my-submodule added at efad0b11c4
13
tests/resources/rebase-submodule/oyster.txt
Normal file
13
tests/resources/rebase-submodule/oyster.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
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.
|
||||
18
tests/resources/rebase-submodule/veal.txt
Normal file
18
tests/resources/rebase-submodule/veal.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
VEAL SOUP.
|
||||
|
||||
Put into a pot three quarts of water, three 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.
|
||||
Reference in New Issue
Block a user