Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Submodule mode / update #1575

Unanswered
smurfix asked this question in Q&A
Discussion options

Updating the submodule references in a supermodule's tree.

for so in repo.submodules:
 sn = git.objects.submodule.base.Submodule(r,rr.head.commit.binsha,name=so.name,path=so.path, mode=0o160000)
 repo.index.add([sn])

(A) an explicit "mode" is required. Given that anything that's not 0o160000 is very likely to break the index file this doesn't make much sense.

(B) There really should be a method that returns a new Submodule object, either using an explicit binsha or defaulting to the submodule's current HEAD, instead of forcing the user to create one from scratch.

You must be logged in to vote

Replies: 2 comments

Comment options

In the docs for submodules there is suggestions for how the API is intended.

Generally, these are very buggy and I wouldn't use them for more than discovery. Further, the index API is superficial at best and again I don't recommend to use it especially when handling submodules. Instead, prefer repo.git.add(...).

You must be logged in to vote
0 replies
Comment options

Well, I did try repo.add(PATH), but that method has the unfortunate side effect of completely ignoring the fact that PATH is a submodule; it adds all the files in it to the supermodule's index instead.

The repo.index.add() method I quoted above at least works. It's even documented.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1574 on April 18, 2023 18:16.

AltStyle によって変換されたページ (->オリジナル) /