Theia: [git] Permission denied issues when executing `pull` and `push`

Created on 12 Oct 2017  路  22Comments  路  Source: eclipse-theia/theia

Moved from: https://github.com/theia-ide/theia/issues/583#issuecomment-336096605
Original message from @marcdumais-work:

I am trying the git extension using my Theia development environment. I have a few remotes defined. ATM I see that for pull and push operations, a random remote is picked (1st returned by "git remote" ?). It happens to be one I do not have permissions to push-to, and that doesn't contain the branch I am working on, so push and pull operations fail. Fetch doesn't seem to do anything and outputs no error message.

I guess these problems will be addressed in this issue by permitting to pick a specific remote for the operations?

push:

The command `git push antoine task` exited with an unexpected code: 1. The caller should either handle this error, or expect that exit code.
To github.com:hexa00/theia.git
 ! [remote rejected]   task -> task (permission denied)
error: failed to push some refs to '[email protected]:hexa00/theia.git'

pull:

The command `git pull antoine` exited with an unexpected code: 1. The caller should either handle this error, or expect that exit code.
You asked to pull from the remote 'antoine', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

PR: #650.

bug

All 22 comments

@marcdumais-work, could you please try the following? Please add process.env.USE_LOCAL_GIT = 'true' to the dugite-git ctor function. Here: https://github.com/theia-ide/theia/blob/e36fa310de84c932bda8eb0561eb88754778ac04/packages/git/src/node/dugite-git.ts#L41

Are you using Linux?

a random remote is picked (1st returned by "git remote" ?).

@marcdumais-work, please correct me if I am wrong, but the default remote should be the origin. The order of the remotes should be defined in the .git/config file. The current logic should pick the first one of them. If it is random in your case, then that is a bug.

Yes, I am on Linux.

Trying your suggestion, I get a series of the following error and the git extension does't seem to work:

The command `git status --untracked-files=all --branch --porcelain=2 -z` exited with an unexpected code: 129. The caller should either handle this error, or expect that exit code.
error: option `porcelain' takes no value
usage: git status [<options>] [--] <pathspec>...
    -v, --verbose         be verbose
    -s, --short           show status concisely
    -b, --branch          show branch information
    --porcelain           machine-readable output
    --long                show status in long format (default)
    -z, --null            terminate entries with NUL
    -u, --untracked-files[=<mode>]
                          show untracked files, optional modes: all, normal, no. (Default: all)
    --ignored             show ignored files
    --ignore-submodules[=<when>]
                          ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)
    --column[=<style>]    list untracked files in columns
(node:12719) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): GitError: error: option `porcelain' takes no value

Could you please tell me what do you get for: which git && git --version && git --exec-path? Thank you!

In my case, it seems that it's not the first remote appearing in .git/config that is selected, but the 3rd one. It's however the first one returned by "git remote".

$ which git && git --version && git --exec-path
/usr/bin/git
git version 2.7.4
/usr/lib/git-core

Your git version seems to be a bit old; it is from 2015. What does it do for you when you execute the following from a local git clone in a terminal: git status --porcelain=2?

$ git status --porcelain=2
error: option `porcelain' takes no value
usage: git status [] [--] ...

-v, --verbose         be verbose
-s, --short           show status concisely
-b, --branch          show branch information
--porcelain           machine-readable output
--long                show status in long format (default)
-z, --null            terminate entries with NUL
-u, --untracked-files[=<mode>]
                      show untracked files, optional modes: all, normal, no. (Default: all)
--ignored             show ignored files
--ignore-submodules[=<when>]
                      ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)
--column[=<style>]    list untracked files in columns

I have the default git that comes with Ubuntu 16.04. A lot of our users are likely to have that version

Currently, we use porcelain version 2 for parsing the status result. We might need to provide a way better error message to the user when the Git version is not supported. Thank you for checking these!

Is there a chance you can bump up your git version, leave the modified dugite-git ctor function and try it out once more? I can do it on a Linux image too. It just takes more time.

@kittaakos no problem, I'll do it

@kittaakos the "porcelain" errors are now gone with a more recent git. I now get the same error when pushing/pulling as originally (1st post above). Did you expect that the origin remote would now be used?

Btw while checking @marcdumais-work git config he was working on a local branch with no upstream attached.

When you use git push from the clit to push that it errors out and asks which upstream to use.

We should do the same.

Is dugite-extra adding --set-upstream ?

Thank you for trying it out, @marcdumais-work! We used to have authentication issues in dugite on Linux, but we have fixed all known issues. I have to set up an Ubuntu image and dig into the problem.

Did you expect that the origin remote would now be used?

The rule should be the following: it uses the first item of the git remote. If that is the origin, then origin should be used.

When you use git push from the clit to push that it errors out and asks which upstream to use.

I am pretty sure we are using the same, unfortunately, it is not visible to the user. (#601?)

Is dugite-extra adding --set-upstream ?

No.

@marcdumais-work, just to make sure I understood it correctly, do you have the same [remote rejected] task -> task (permission denied) problem when you have a single remote, or it works correctly? Thanks!

@kittaakos yes, when I keep a single remote (my own fork) I can then pull and push.

Merging #638.

  • Start application.

    • Clone a git repository into your workspace.

    • Refresh the UI so that client will be informed of the new repository.

    • Kill application.

    • Delete the cloned repository outside from Theia.

    • Restart the application.

~It tries to watch the non-existing repository which throws an error each second. Even if the client state restoration is not super sophisticated, the watcher should be smart enough to unregister itself if the target repository does not exist anymore.~

This was fixed via https://github.com/theia-ide/theia/commit/5de4db8f119f622bb38dc27ec0ac0922f0d149a1#diff-392c37f87fa84f7102bfb5248b4837d8

Merged #583.

Pulling from a remote which is not configured to be the default remote for the currently active branch, the branch has to be explicitly specified too.

For instance, if the origin is the default, one can call git pull which will include the remote branch from origin to the currently active branch.

When pulling from another remote, for example, upstream, then branch has to be given as well: git pull upstream master. We need to support it in the Git specific quick open service.

~We will mimic VSCode, and open the quick open widget twice. First with the remote, then the branch.~

Update: The is done by 6c9916af2052adca2c99e38d75af9a444dbca41a.

~Since git commands can be executed from the quick open service, we might need to provide the repository context for that. So when the gitRepositoryProvider's getSelected is undefined, then we should list all the repositories, and the user should be able to select one.~

This was fixed via: https://github.com/theia-ide/theia/commit/58a4aac36879a09a22076943e3a274825fc2f5fb#diff-155ba606ae09e4f27403231b020ed993

~I am aware of some oddities in the Git repositories dropdown when copying/removing Git clones from the WS. I will take care of it as part of this task.~

cd5c36db2daf21ee5d5f752a93f4e546b1035dce

~Add required Git version to the documentation. The version should support --porcelain=2 for getting the status. The update should go here: https://github.com/theia-ide/theia/blob/master/doc/Developing.md#prerequisites.~

It is supported from 2.11.0. See commit here.

Added via https://github.com/theia-ide/theia/pull/650/commits/d388049e7ca1b1e7a72a902a8fb612c9f51a93a3.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marechal-p picture marechal-p  路  3Comments

Beetix picture Beetix  路  3Comments

dhananjayharel picture dhananjayharel  路  3Comments

pwFoo picture pwFoo  路  3Comments

fangnx picture fangnx  路  3Comments