Daniel
Daniel

Reputation: 3063

Automating Qt build - Submodule issue. Can not get a clean working directory

I want to automate the build process for specific Qt versions. According to the Qt wiki the commands for this are

git clone https://code.qt.io/qt/qt5.git
git checkout v5.9.0
git submodule update --init --recursive

This worked and the result was a clean working directory with version 5.9.0 checked out. Now i checked out version 5.8.0 with the commands

git checkout v5.8.0
git submodule update --init --recursive

During the update there were some warnings that some directories could not get removed because they are not empty. And now the result of git status looks like this

HEAD detached at v5.8.0
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

        modified:   qtdeclarative (untracked content)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        qtremoteobjects/

In the Qt Wiki the cleaning process is stated as

git submodule foreach --recursive "git clean -dfx" && git clean -dfx

When executing this command there are messages that some directories are skipped - But not stated why. Therefore the working directory still contains untracked content.

Anyone knows which magical commands work to really get a clean working directory?

Upvotes: 0

Views: 518

Answers (1)

Daniel
Daniel

Reputation: 3063

If you carefully read the manpages of git clean you will see that it states:

Git will refuse to delete directories with .git sub directory or file unless a second -f is given.

Therefore to really get a clean directory tree you have to do the cleanup like this

git submodule foreach --recursive "git clean -dffx" && git clean -dffx

This will remove the repositories completetly though. So if you switch to another version which contains the submodule - It has to be cloned again.

Upvotes: 2

Related Questions