Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6194889

Browse files
committed
Merge pull request libgit2#3500 from ethomson/submodules_with_path
Handle submodules with paths in `git_submodule_update`
2 parents 5aa28a8 + f4b0267 commit 6194889

16 files changed

+95
-24
lines changed

src/submodule.c

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,6 @@ static int submodule_update_head(git_submodule *submodule)
14231423
return 0;
14241424
}
14251425

1426-
14271426
int git_submodule_reload(git_submodule *sm, int force)
14281427
{
14291428
int error = 0;
@@ -1433,35 +1432,30 @@ int git_submodule_reload(git_submodule *sm, int force)
14331432

14341433
assert(sm);
14351434

1436-
/* refresh index data */
1437-
if ((error = submodule_update_index(sm)) < 0)
1438-
return error;
1439-
1440-
/* refresh HEAD tree data */
1441-
if ((error = submodule_update_head(sm)) < 0)
1442-
return error;
1435+
if (!git_repository_is_bare(sm->repo)) {
1436+
/* refresh config data */
1437+
mods = gitmodules_snapshot(sm->repo);
1438+
if (mods != NULL) {
1439+
error = submodule_read_config(sm, mods);
1440+
git_config_free(mods);
14431441

1444-
/* done if bare */
1445-
if (git_repository_is_bare(sm->repo))
1446-
return error;
1442+
if (error < 0)
1443+
return error;
1444+
}
14471445

1448-
/* refresh config data */
1449-
mods = gitmodules_snapshot(sm->repo);
1450-
if (mods != NULL) {
1451-
error = submodule_read_config(sm, mods);
1452-
git_config_free(mods);
1446+
/* refresh wd data */
1447+
sm->flags &=
1448+
~(GIT_SUBMODULE_STATUS_IN_WD |
1449+
GIT_SUBMODULE_STATUS__WD_OID_VALID |
1450+
GIT_SUBMODULE_STATUS__WD_FLAGS);
14531451

1454-
if (error < 0) {
1455-
return error;
1456-
}
1452+
error = submodule_load_from_wd_lite(sm);
14571453
}
14581454

1459-
/* refresh wd data */
1460-
sm->flags &=
1461-
~(GIT_SUBMODULE_STATUS_IN_WD | GIT_SUBMODULE_STATUS__WD_OID_VALID |
1462-
GIT_SUBMODULE_STATUS__WD_FLAGS);
1455+
if (error == 0 && (error = submodule_update_index(sm)) == 0)
1456+
error = submodule_update_head(sm);
14631457

1464-
return submodule_load_from_wd_lite(sm);
1458+
return error;
14651459
}
14661460

14671461
static void submodule_copy_oid_maybe(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "testrepo"]
2+
path = lib/testrepo
3+
url = ../testrepo.git
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/master
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[core]
2+
repositoryformatversion = 0
3+
filemode = false
4+
bare = false
5+
logallrefupdates = true
6+
symlinks = false
7+
ignorecase = true
8+
hideDotFiles = dotGitOnly
253 Bytes
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 commit comments

Comments
 (0)