gitbutler icon indicating copy to clipboard operation
gitbutler copied to clipboard

Support repositories with submodules in them

Open krlvi opened this issue 1 year ago • 22 comments

krlvi avatar Feb 14 '24 10:02 krlvi

Any status on when this will be added? Love GitButler but using submodules in all my projects

ericwern avatar Feb 22 '24 09:02 ericwern

Same, not working

PierreLeGuen avatar Feb 23 '24 17:02 PierreLeGuen

Any idea why GitButler is currently unable to support submodules?

pharapeti avatar Mar 12 '24 05:03 pharapeti

See #2891. This issue disallowed opening repos with submodules due to a bug that would mess up the submodule.

This issue also seems to be a duplicate of #2541. Which mentions that submodule support is on the list.

Geekdude avatar Mar 12 '24 16:03 Geekdude

Same issue here. All of my personal projects plus the public projects I contribute to contain submodules.

eightycc avatar Mar 13 '24 15:03 eightycc

Waiting for this feature, submodules are heavily utilized in my repos.

himchawla avatar Mar 21 '24 08:03 himchawla

In all cases, GitButler should not rejecting a repository if it has submodules. It should just ignore submodules and work if there were no submodules.

I don't care about changes in the sub modules, I just want to work on the main repository using git butler!

It is even OK if git bulter removes all files in the sub modules - https://github.com/gitbutlerapp/gitbutler/issues/2891#issuecomment-1963020585

koppor avatar Mar 22 '24 08:03 koppor

Even as an initial pass, it would be helpful if users could scope to a submodule and only make commits within that one submodule.

I work in submodules every day, so having this feature would be huge (and essential) to my use of git butler.

In my use case, deleting files from a submodule would be problematic, so the outright rejection is much better than the alternative of damaging the repository or database. Much appreciated.

tkuhlengel avatar Apr 16 '24 19:04 tkuhlengel

There at least should be an option to override this behaviour, accepting any risk it might have so that we can just work with the submodule. It might be a screen we need to accept, a config we need to change somewhere. Is there an option like this?

limonkufu avatar Apr 16 '24 20:04 limonkufu

@limonkufu

There at least should be an option to override this behaviour, accepting any risk it might have so that we can just work with the submodule. It might be a screen we need to accept, a config we need to change somewhere. Is there an option like this?

Sort of. GitButler only appears to check for submodules when adding a repo, and it does so by checking for a .gitmodules file in the root of the repo.

Thus, if you rm .gitmodules and then add the repo, it will let you. And then you can just restore that file with git checkout .gitmodules (and GitButler will be none the wiser).

[!warning] You are on your own here. I have no idea how GitButler messes up submodules. My assumption is that you should avoid touching submodules and submodule code entirely when using GitButler, but even that might be unsafe. Test how it works in a test repo. Don't yell at me if this goes wrong.

markjaquith avatar Apr 19 '24 14:04 markjaquith

For everyone else who finds this from Google, you may not realize this is an issue because the error is hidden when clicking: Screenshot 2024-04-25 at 12 16 31 PM Screenshot 2024-04-25 at 12 16 38 PM

ericclemmons avatar Apr 25 '24 17:04 ericclemmons

Thanks for sharing! Please note that this is a regression in the latest stable release (Version 0.11.4 (20240423.110032), and it's fixed in nightly.

Byron avatar Apr 25 '24 20:04 Byron

@markjaquith thanks, I am willing to take the risk and my usecase is just read only submodules. If you want me to test something specific I can have a look at that as well as your tester?

limonkufu avatar Apr 26 '24 08:04 limonkufu

I tried everything but it still gives me the same error.

I tried everything described here: https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule

  • rm .gitmodules
  • git submodule deinit
  • git rm <submodule>
  • rm <submodule>
  • rm .git/module

Could you advise how I can make it work by deleting an existing submodule? I didn't commit any of the changes though

limonkufu avatar Apr 26 '24 08:04 limonkufu

Can you share the errors you see? When adding a project, it essentially only looks at .gitmodules and if present, rejects the repository. In a way, it would be unexpected if it would still think submodules are present without .gitmodules.

Byron avatar Apr 26 '24 09:04 Byron

yeah sure.

I don't have any .gitmodules in the repo.

ls -all .gitmodules
ls: cannot access '.gitmodules': No such file or directory

Then, I try opening the repository with Gitbutler by using "Add new project" button. I get the following in console:

[Error] ipc->add_project: {"path":"/Users/u.yilmaz/dev/ska-cicd-automation"} (2)
Error: Repositories with git submodules are not supported
{code: "errors.projects", message: "Repositories with git submodules are not supported"}
	(anonymous function) (user.3f3fe2e4.js:4:240)
	(anonymous function) (ipc.21fc29f2.js:1:2241)
image

limonkufu avatar Apr 26 '24 13:04 limonkufu

Do you still have it in the index? If that's the case, git checkout .gitmodules work work despite ls .gitmodules failing. If that's the case, now GitButler is smart enough to get the .gitmodules file from the index, which is also what Git does I believe. This can be put to the test of course, but git submodule should list something.

Byron avatar Apr 26 '24 13:04 Byron

ah okay that was it. I didn't think removing from the index was also needed. Thanks 👍

limonkufu avatar Apr 26 '24 14:04 limonkufu

Would it be unreasonable to change this from an error to a warning and prompt to "Continue at your own risk" (or whatever the risk actually is?)

Or perhaps cross-linking this issue or discussion to up-doot for support.

ericclemmons avatar May 20 '24 22:05 ericclemmons

I would second @ericclemmons suggestion.

aviv-vladimirsedlar avatar May 21 '24 12:05 aviv-vladimirsedlar

I think previously there was data-loss when the code operated on Git indices with submodules, hence it was quickly forbidden entirely. However, I also see why submodule support is important and made sure it's on a ping on the radar of the devs.

Byron avatar May 21 '24 14:05 Byron

Would it be unreasonable to change this from an error to a warning and prompt to "Continue at your own risk" (or whatever the risk actually is?)

Or perhaps cross-linking this issue or discussion to up-doot for support.

This is a very good point. A dirty "hack" you could do is to remove the .gitmodules file only while adding the repo (and then re-adding it). The app already tries to ignore submodules in it's normal operation but there is some condition under which it doesn't handle it correctly, and I havent discovered yet what that conditions is

krlvi avatar May 21 '24 14:05 krlvi

Just installed Gitbutler so this is my 5 minute experience with it.

  1. Connect Github 👍
  2. Add a local Repo - "Gitbutler isnt supporting submodules" 👎

Removing the .gitmodules didnt solve the issue.

That was a very frustrating onboarding. I feel like submodules are essential & since almost all my repos have some sort of submodules I wont even bother trying Gitbutler for now, which is a huge shame

phifuh avatar Jun 23 '24 07:06 phifuh

Hello! The latest release 0.12.6 now allows adding of repos with submodules. Here is a full changelog entry for that version - https://discord.com/channels/1060193121130000425/1183737922785116161/1255135073242583122

Let me know how it works for you! Feel free to ping me here or on discord.

@phifuh (and everybody else) - i am sorry for the shitty onboarding. I hope it works correctly for you now in the new release

krlvi avatar Jun 25 '24 12:06 krlvi

the shitty onboarding.

🤣

sschuberth avatar Jun 25 '24 13:06 sschuberth

It's pre-1.0 I'm sure most of us understand that this is a work-in-progress and are just excited and grateful to see all this work being performed out in the open <3

jokeyrhyme avatar Jun 26 '24 02:06 jokeyrhyme

Okay, I was able to add https://github.com/pop-os/cosmic-epoch to GitButler in 0.12.6, and I just bumped all the submodules locally

nu ❯ git status
## gitbutler/integration
 M cosmic-applets
 M cosmic-applibrary
 M cosmic-bg
 M cosmic-comp
 M cosmic-edit
 M cosmic-files
 M cosmic-greeter
 M cosmic-icons
 M cosmic-launcher
 M cosmic-notifications
 M cosmic-osd
 M cosmic-panel
 M cosmic-randr
 M cosmic-screenshot
 M cosmic-session
 M cosmic-settings
 M cosmic-settings-daemon
 M cosmic-store
 M cosmic-term
 M cosmic-workspaces-epoch
 M xdg-desktop-portal-cosmic

But GitButler doesn't display or seem to detect this as a change that needs to be branched / committed, it just has the "you are up to date" message

Then I made a change to a non-submodule file, which GitButler does detect properly, but it still doesn't offer to version those submodule reference changes

So it does indeed load the repository and function with non-submodule changes now, yay

jokeyrhyme avatar Jun 27 '24 01:06 jokeyrhyme

That's great to hear!

I also think that's the expected behaviour, as it ignores all submodule changes outright.

Byron avatar Jun 27 '24 06:06 Byron

It is working as expected. The submodules are ignored.

aviv-vladimirsedlar avatar Jul 02 '24 12:07 aviv-vladimirsedlar

Okay, at this point I will close this issue as completed. Thank you all for your patience with us. If you come across any issues related to submodules or anything else, GitHub issues are very much welcome and appreciated! (or pinging us on discord)

krlvi avatar Jul 02 '24 13:07 krlvi