0

I want to get source code of some Qt modules. I don't need change history and most of Qt submodules so I decided to clone Qt Git repo and init & update some modules:

git clone --branch v5.10.1 --depth 1 git://code.qt.io/qt/qt5.git source
cd source
git submodule update --init --depth 1 qtbase qtlocation

However, when I'm trying to run code above it gives me following error:

fatal: The remote end hung up unexpectedly
Fetched in submodule path 'qtbase', but it did not contain 6c6ace9d23f90845fd424e474d38fe30f070775e. Direct fetching of that commit failed.

If I'm trying to init & update all submodules, it works:

git clone --branch v5.10.1 --depth 1 git://code.qt.io/qt/qt5.git source
cd source
git submodule update --init --depth 1

How can I get source code of git repo including some submodules without version history?

Kamil Zaripov
  • 904
  • 11
  • 33
  • Possible duplicate of [How to make shallow git submodules?](https://stackoverflow.com/questions/2144406/how-to-make-shallow-git-submodules) – phd Jun 12 '18 at 20:05
  • *this option isn't usable for submodules which don't track master very closely. If you set depth 1, then submodule update can only ever succeed if the submodule commit you want is the latest master.* – phd Jun 12 '18 at 20:05
  • Well, now it pretty clear. So how can I download exact version of submodule without downloading all history? – Kamil Zaripov Jun 12 '18 at 20:57
  • Increse `--depth` so that the history includes commit `6c6ace9`. – phd Jun 12 '18 at 21:46
  • Answer for my question: https://stackoverflow.com/questions/27188899/shallow-clone-with-submodules-in-git-how-to-use-pointed-commits-and-not-latest – Kamil Zaripov Jun 25 '18 at 15:44

1 Answers1

0

I'm doing something similar in Ubuntu 18.04 with the most recent whole version. To do it, I set ver equal to a git ls-remote that greps out whole number versions then sorts ascending and grabs the last one. At the time of this writing the result was 5.12.1

ver="$(git ls-remote --heads https://code.qt.io/qt/qt5.git | grep -Pio '(?<=refs/heads/)[\d\.]+' | sort -V | tail -1)" ; git clone --depth 1 --branch $ver https://code.qt.io/qt/qt5.git

This one's a bit more complex. First we'll zero in on the module groups essential addon preview deprecated listed in .gitmodules. From there I'll step back to the heading for each and filter out those that don't contain qtweb qtwin qtmac qtandroid qtpurch. I'll iterate through the list performing a shallow clone of each, based on its defined branch version.

for value in $(grep -B10 -Pi 'status = (essential|addon|preview|deprecated)' .gitmodules | grep -Pio '(?<=\[submodule \")(?!qt(web|win|mac|android|purch)).*(?=\"\])' | sort); do git clone --depth 1 --branch $(grep -A6 -Pi "(?<=\[submodule \")$value(?=\"\])" .gitmodules | grep -Pio '(?<=\tbranch = ).*') https://code.qt.io/qt/"$value".git ; done

For me, the end goal was to do a static build, so I'll just note the options I used:

./configure -prefix $PWD/qtbase -static -confirm-license -opensource -ltcg -optimize-size -ccache -no-pch -skip webengine -nomake tests -nomake examples
noabody
  • 179
  • 4