Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with git submodules #8

Closed
Javex opened this issue Jan 25, 2014 · 12 comments
Closed

Problems with git submodules #8

Javex opened this issue Jan 25, 2014 · 12 comments

Comments

@Javex
Copy link

Javex commented Jan 25, 2014

Short: When I run git up it does not run on my current working directories' git repository.

Long: I have a master repository that has several submodules. To keep everything synced, I run git pull && git submodule foreach pull (and some more commands). This worked but always caused problems when pushing later. As I understand git up solves this. However, I noticed that git up seems to be running on the master each time in the submodule.

For example, the master module has the branches master and reduced while one submodule only has master and no reduced. However, this is the output produced when running above command (with only one submodule):

Fetching origin
stashing 1 changes
master   up to date
reduced  up to date
unstashing
Entering 'mysubmodule'
Fetching origin
stashing 1 changes
master   up to date
reduced  up to date
unstashing

Making things even more weird, when I go into the directory myself and do git up, the same thing happens:

stashing 1 changes
master   up to date
reduced  up to date
unstashing

There isn't even a change in this directory, only in the master. I read up on PyGit docs so I ran this: GIT_PYTHON_TRACE=y git up:

git status --porcelain --untracked-files=no
git config git-up.rebase.auto
git config git-up.rebase.log-hook
git config git-up.bundler.rbenv
git config git-up.bundler.check
git config git-up.bundler.autoinstall
git config git-up.updates.check
git config git-up.fetch.prune
git config git-up.bundler.local
git config git-up.fetch.all
git config git-up.rebase.arguments
git version
git fetch --multiple --prune origin
Fetching origin
git cat-file --batch-check
git diff HEAD --cached --abbrev=40 --full-index --raw
git diff --abbrev=40 --full-index --raw
git status --porcelain --untracked-files=no
stashing 1 changes
git stash
master   up to date
reduced  up to date
unstashing
git stash pop

It still doesn't say that much about what's really going on though :(
But I executed some of the commands myself and it does behave differently, for example git fetch --multiple --prune origin did delete a branch on the first run but not on the second, indicating this command was never executed on this repository.

Since I don't know so much about PyGitUp (or PyGit for that matter), I don't know how to debug this efficiently (I am capable of Python though, so I can assist there). I am not sure if I have a major configuration screwup or if this is a bug in PyGitUp but if someone could provide details on how to track this down, I would be very happy.

@msiemens
Copy link
Owner

Hey Javex! Does this problem occur, when not using submodules or only with submodules?

@Javex
Copy link
Author

Javex commented May 19, 2014

Sorry for the late reply, it only happens inside a submodule.

@msiemens msiemens changed the title git up not running on current repository Problems with git submodules Jul 28, 2014
@msiemens
Copy link
Owner

Sorry for letting this wait for much too long! Did I hear you right that you want a git up in a repo with submodules to update every submodule, too?

@Javex
Copy link
Author

Javex commented Feb 13, 2015

Yes. The particular problem (which git up perfectly describes & solves) is that I need to pull and merge each branch before pushing. Since I do that with submodules (i.e. git submodule foreach git pull then git submodule foreach git push) a conflict happening anywhere in between breaks my sequence. git up does/would solve this except for the described issue

@msiemens
Copy link
Owner

It seems like the problem is that PyGitUp will always seek the toplevel repo (the output of git rev-parse --show-toplevel). But the git library (GitPython) has native support for submodules, so maybe we could use that. In that case, you'd run git up on the toplevel repo and PyGitUp would automatically update all submodules, too.

msiemens added a commit that referenced this issue Feb 21, 2015
@msiemens
Copy link
Owner

I've updated PyGitUp so it should work. Could you try the latest dev version, if it actually works?

@Javex
Copy link
Author

Javex commented Feb 21, 2015

As far as I understand you, you wanted to update all submodules inclusively, too. When I run git up it does not do that. However, running git submodule foreach git up now seems to work in each directory correctly.

I did not have any changes right now, so I could not test the actual functionality, i.e. whether it behaves correctly on all branches even if there are changes. But that's just basic git up stuff that I suppose is independent of it being a submodule.

So in short: Thank you very much. That saves me a lot of trouble, awesome :)

@msiemens
Copy link
Owner

When I run git up it does not do that. However, running git submodule foreach git up now seems to work in each directory correctly.

Yeah, I forgot to mention that PyGitUp now works with git submodule foreach [...] but itself doesn't update submodules 😄

@msiemens
Copy link
Owner

I've now released v1.2.2 which includes the fix :)

@kuboj
Copy link

kuboj commented Jan 11, 2016

Yeah, I forgot to mention that PyGitUp now works with git submodule foreach [...] but itself doesn't update submodules 😄

Is there some rationale behind this? To, by default, not update submodules if git up is executed in top directory. I was pretty confused by this behavior when I started using this port of git-up :)

@msiemens
Copy link
Owner

Is there some rationale behind this? To, by default, not update submodules if git up is executed in top directory. I was pretty confused by this behavior when I started using this port of git-up :)

The rationale is that the original git-up doesn't update submodules when called from the root directory and I want to keep the behaviour of PyGitUp in line with it. Actually, the original breaks if called in a submodule (e.g. aanand/git-up#111) whereas PyGitUp handles it without errors :)

@kuboj
Copy link

kuboj commented Jan 18, 2016

Ok, fair enough, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants