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

Add config to allow file protocol to be used-Tests #10389

Merged
merged 6 commits into from Nov 22, 2022

Conversation

vbjay
Copy link
Contributor

@vbjay vbjay commented Nov 12, 2022

Fixes #10387 for tests. Will reopen issue and tie to second pull request.
Closes #10394

Proposed changes

  • Add config to allow file protocol.

Test methodology

  • Run tests and confirm tests succeed

Test environment(s)

  • GIT
  • Windows

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned vbjay Nov 12, 2022
@vbjay
Copy link
Contributor Author

vbjay commented Nov 12, 2022

Looking into

Modules: repo1 repo1/repo2
Expected is <System.String[3]>, actual is <System.Collections.Generic.List`1[System.String]> with 2 elements
Values differ at index [2]
Missing: < "repo1/repo2/repo3" >

debugged and got temp path

tree /A |clip
\---repo0
    \---repo1
        \---repo2

@vbjay
Copy link
Contributor Author

vbjay commented Nov 12, 2022

Confirmed fixed both in test and adding a submodule in UI

image

Only thing left is to adjust config to allow the protocol on all submodule commands. Looks like submodule update needs it too.

@vbjay vbjay force-pushed the fix/10387 branch 3 times, most recently from 5fc0ee1 to 826e762 Compare November 12, 2022 19:11
@vbjay
Copy link
Contributor Author

vbjay commented Nov 12, 2022

Last to check are the SubmoduleStatusProviderTests.

image

@vbjay vbjay force-pushed the fix/10387 branch 2 times, most recently from a5037db to 985cb48 Compare November 13, 2022 14:06
@vbjay
Copy link
Contributor Author

vbjay commented Nov 13, 2022

Please hold up. I am doing this methodically. I just got tests green. I am now going to play with what the different configs do. I did make this Pull request WIP for a reason.

@vbjay
Copy link
Contributor Author

vbjay commented Nov 13, 2022

What user means:
user - protocol is only able to be used when GIT_PROTOCOL_FROM_USER is either unset or has a value of 1. This policy should be used when you want a protocol to be directly usable by the user but don’t want it used by commands which execute clone/fetch/push commands without user input, e.g. recursive submodule initialization.

found at https://git-scm.com/docs/git-config#Documentation/git-config.txt-protocolallow

So user basically breaks recursive submodule update --init and add.

GetSubmodulesLocalPaths test:
image

git -c protocol.file.allow=user submodule add -f "C:/Users/vbjay/AppData/Local/Temp/ymhgxebg.gsp/repo3/" "repo3"
image

at GitCommands.ExecutableExtensions.d__9.MoveNext() in C:\git\gitextensions\GitCommands\Git\ExecutableExtensions.cs:line 326

user and never result in
image

@vbjay vbjay force-pushed the fix/10387 branch 2 times, most recently from 985cb48 to b1faf06 Compare November 13, 2022 15:45
@vbjay vbjay changed the title WIP Add config to allow file protocol to be used Add config to allow file protocol to be used Nov 13, 2022
@vbjay
Copy link
Contributor Author

vbjay commented Nov 13, 2022

Ok. now ready for review.

@vbjay vbjay changed the title Add config to allow file protocol to be used WIP Add config to allow file protocol to be used Nov 13, 2022
@vbjay
Copy link
Contributor Author

vbjay commented Nov 13, 2022

image
image
image

Even setting default repo config fails the submodule add. They require -c...
git submodule add -f "C:/Users/vbjay/AppData/Local/Temp/piibmzoi.jod/repo3/" "repo3"
image


While
image
image

works

@vbjay
Copy link
Contributor Author

vbjay commented Nov 13, 2022

This work will be the basis for another pull request that will define ui popup functionality based on needed ui interaction to allow command.

@RussKie @gerhardol . Review this and let me know if you have feedback. This gets tests green and lays the foundation for a ui user allows x functionality built on the work here.

@vbjay vbjay changed the title WIP Add config to allow file protocol to be used Add config to allow file protocol to be used Nov 13, 2022
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too tired to review...

GitCommands/Git/Commands/GitCommandHelpers.cs Outdated Show resolved Hide resolved
@RussKie
Copy link
Member

RussKie commented Nov 16, 2022

Can you please re-enable all tests that were disabled in fe1d5b2?

@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Nov 16, 2022
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
Enable tests as Russkie suggested.
Looks fine, not much else to do I assume.
I would would prefer a string instead of the nullable configs argument in GitCommandHelpers.cs, no strong opinion.

GitCommands/Git/Commands/GitCommandHelpers.cs Outdated Show resolved Hide resolved
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Nov 16, 2022
@vbjay vbjay force-pushed the fix/10387 branch 2 times, most recently from 8266b96 to 95ace52 Compare November 17, 2022 00:21
@RussKie
Copy link
Member

RussKie commented Nov 18, 2022 via email

@vbjay vbjay changed the title Add config to allow file protocol to be used Add config to allow file protocol to be used-Tests Nov 18, 2022
vbjay added a commit to vbjay/gitextensions that referenced this pull request Nov 21, 2022
gitextensions#10389 (comment)

Co-authored-by: Michael Seibt <36601201+mstv@users.noreply.github.com>
vbjay added a commit to vbjay/gitextensions that referenced this pull request Nov 21, 2022
gitextensions#10389 (comment)

Co-authored-by: Michael Seibt <36601201+mstv@users.noreply.github.com>
@vbjay
Copy link
Contributor Author

vbjay commented Nov 21, 2022

See https://bugs.launchpad.net/ubuntu/+source/git/+bug/1993586 along with https://github.blog/2022-10-18-git-security-vulnerabilities-announced/#fn-67904-1 for details. I have tried with never, and user. Always is required and at least with git for windows even setting config in git config protocol.file.allow always fails this as shown in the AddSubmodule code found at

image

I left this code in to make sure that adding submodules still works down the road.

Since we are in direct control of what the repo is and what are in the submodules for the tests, we can set always to true for tests. For the program we will need to rethink adding submodules and submodule update --recursive. Git has locked it down HARD. This pull request is ONLY concerned with making tests work again.

The next pull request will be started after this is merged. That work will entail us forgoing recursive submodule work, or asking user if it trusts the repos in submodule chain and if so, we pass in the config to always. Started #10426 to discuss this

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for making the tests work again and for all the testing.

@mstv
Copy link
Member

mstv commented Nov 22, 2022

I tend to rebase and merge this PR in order to keep the commits (although some are tiny). This merge strategy has the disadvantage that no reference to this PR is added.

@vbjay
Copy link
Contributor Author

vbjay commented Nov 22, 2022

I can rebase and force push if you want.

@vbjay
Copy link
Contributor Author

vbjay commented Nov 22, 2022

Should be able to just merge now. @mstv

@mstv
Copy link
Member

mstv commented Nov 22, 2022

I tend to rebase and merge this PR in order to keep the commits (although some are tiny). This merge strategy has the disadvantage that no reference to this PR is added.

I can rebase and force push if you want.
Should be able to just merge now. @mstv

There is no need to manually rebase. This can be done using grafik.

We want to avoid unnecessary merge commits. I want to discuss

  • whether we should keep such commits
  • how to merge including a reference to the PR

@vbjay
Copy link
Contributor Author

vbjay commented Nov 22, 2022

whether we should keep such commits

I follow the idea of atomic commits. I try to keep changes as small as possible so that reviews are easier. If you squash then it gets hairy understanding work like this. The add config is pretty big but is clear on what it is doing. So I prefer commits stay.

how to merge including a reference to the PR

I can reword last commit and add a reference to pull request if you like.

@mstv
Copy link
Member

mstv commented Nov 22, 2022

I can reword last commit and add a reference to pull request if you like.

Yes, please.

We can continue the generic discussion after merging.

@vbjay
Copy link
Contributor Author

vbjay commented Nov 22, 2022

Next step is to get the core team to opine on #10426. This pull request started the plumbing on how to pass in the config when needed. The discussion is there for how do we want the program to act. I don't want to go down a rabbit hole and have to rework. Please discuss there and let's get a direction on the discussion and then from discussion I'll wire up the expected functionality in the gui.

@mstv mstv merged commit efe3b72 into gitextensions:master Nov 22, 2022
@ghost ghost added this to the vNext milestone Nov 22, 2022
@mstv
Copy link
Member

mstv commented Nov 22, 2022

Thank you

@vbjay vbjay deleted the fix/10387 branch November 22, 2022 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding file ( local folder) submodules broke since git version 2.38.1
4 participants