Git remote add doesn't add a remote in QtCreator



  • I tried a to add a remote via extras->Git->remote repositories-> manage remotes.
    My success was small, since no remote was added to the remote list in QtCreator, although the git command was correct.
    Using Git with the console shows me the remote, name and path are both ok.
    Now I could do all the push and pull stuff over the console, but this is so cumbersome.
    But with no added remote in QtCreator, pushing doesn't work there.

    Qt Version is 5.1
    QtCreator is 2.7
    I created the git project repository with QCreator, while the remote repo was created manually by me with the --bare option.
    OS is Vista.


  • Moderators

    Creator runs "git remote -v" in the top level directory of the repository to get the remotes. Are your remotes listed in that command?



  • As I said, they are, at least in the console.
    Only QtCreator doesn't want to show me them.


  • Moderators

    It works fine for me... all remotes are listed in Tools>Git>Remote Repository>Manage Remotes. I can also add new remotes there and see them in the console.

    I do use a built pretty close to the upcoming Qt Creator 2.8 release. Maybe this was fixed in the meantime. Orgad and Petar did put quite a bit of work into the git support since 2.7.

    Could you try a snapshot from "here":http://download.qt-project.org/snapshots/qtcreator/2.8.0/ ...



  • Tried the latest snapshot for windows with no success. While I can add remotes with QtCreator, I can see them only in the console but not in QtCreator itself.


  • Moderators

    Did you "file a bug report":https://bugreports.qt-project.org/ about this yet? I can not look into this right away and will forget about it without a report:/



  • Ok, I'll do it.

    By the way, I tested it on my Ubuntu with the same sdk (it's also the same laptop, I got both Vista and Ubuntu on it) and it works perfectly.
    However, the Qt project on Ubuntu was created from the already existing project and I created a new repo, which I added as a remote succesfully.
    So on Ubuntu, I had two repos, one origin and one I added by myself.

    Now I tried the same on Vista with the result, that after creating from an exsiting git repo, I don't even get an origin repo. All files, on the other hand, were cloned perfectly.

    (I'll add all this in my bug report as well)



  • So, I stepped into QtCreator and found some interesting things.

    First, QtCreator doesn't like whitespaces in paths when it wants to show them.
    Here's the affected code from gitclient.cpp in method synchronousRemotesList:

    @QStringList tokens = remote.split(QRegExp(QLatin1String("\s")),
    QString::SkipEmptyParts);
    if (tokens.count() != 3)
    continue;@

    I didn't check what the QRexExp part is exactly doing, but appereantly it splits the string at whitepaces, so my path F:\project repos\QtSimpleApp was splitted into four tokens and therefore not added to the list.

    However QtCreator will add such whitespaced paths to the remote list of the git repository which was the reason I could see them in the console.
    Adding the same URL in the console will generate in error on the other hand, so I don't know if this behavior is all right. Maybe im missing just a configuration option in Git.

    On Ubuntu I hadn't these problems, because it didn't allow me to create a new directory in the console with a whitespace in it.
    But there was another thing why it worked on Ubuntu and not on Vista.
    If QtCreator doesn't find any remotes in the git repository, it will not update the working directory in the remotemodel.
    Here are the code parts from remotedialog.cpp and remotemodel.cpp:

    @void RemoteDialog::refresh(const QString &repository, bool force)
    {
    //..
    } else {
    QString errorMessage;
    if (!m_remoteModel->refresh(m_repository, &errorMessage))
    VcsBase::VcsBaseOutputWindow::instance()->appendError(errorMessage);
    }
    }@

    @QMap<QString,QString> remotesList =
    m_client->synchronousRemotesList(workingDirectory, errorMessage);

    if (remotesList.isEmpty())
        return false;@
    

    It seems that the refresh method of remotedialog is only called when the dialog is opened. The refresh button will call another method:

    @void RemoteDialog::refreshRemotes()
    {
    refresh(m_remoteModel->workingDirectory(), true);
    }@

    The problem is now, if you have no remotes in your git repository, then the variable m_workingDirectory will not be set, therefore every remote operation will fail.
    On the other hand, if you already have one remote, as I had on Ubuntu since I cloned it, it will work just fine.

    I hope I could describe everything clear enough.

    So my suggestions are:
    First, put the assignment of the working directory above the test for an empty remote list, if this have no other consequences, to make adding remotes possible even if it's the first one.
    Second, either don't allow whitespaced URLs or change the QRegExp Part, so that they are correctly handled.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.