All packages with git source always checkout and rebuild

Every time with I type make, all packages using git source always checkout out a copy and rebuild, but packages with gzip/xz/bzip source will not rebuild if no changes.
Is there any option to skip git source rebuild if there is no changes?

If you have properly defined PKG_MIRROR_HASH in Makefile, the cloned/saved git tar.xz will be used next time.

Pretty much all git using packages in OpenWrt define that, so I assume that you have some private packages that you are talking about.

See example in;a=blob;f=net/dawn/Makefile;h=193fbaf67f7086b68934cdefa692396b6c1e62d9;hb=HEAD

I do not think a same git version packed by xz with different arch and xz version , will got the same HASH value. Even pack a file with xz the same arch and version, but different compress level 1..9, the HASH value also diffrent.
So the author of Makefile write a HASH value, by his environment, others clone git source and use different xz version will result different HASH.
I think tar ball suffix .tar can always get the same HASH when git clone a version. But tar ball suffix .tar.xz may not.

Well, it works for buildbot and has always worked for me.

Note that the "git clone and pack as tar.xz" routine it OpenWrt acts in a predefined way. Just check the logic from the download scripts. The sha256 of the created file should stay the same.

Yes if you write the Makefile, it must worked for you, but not always worked for others.
I think a name sorted tar ball of git clone, without compress, will worked for everyone.

Or just check the .tar.xz package's filename which have a git version string, if it is the same with Makefile PKG_SOURCE_VERSION value. git version is unique, do not need HASH again.
As an option.

I do not think a same git version packed by xz with different arch and xz version , will got the same HASH value.

Yes, you are quite correct. PKG_HASH_MIRROR is NOT stable across "builder" distributions. We had massive headaches with openwrt-19.07+ and some internal packages now that it has been made mandatory.

If we run the build (and thus the git-clone + repack into a tarball) under Ubuntu 18 LTS, we get a different hash than when we do so in our Debian 10 docker builder.

I have not looked in depth for the reasons, but evidently there are non-deterministic steps involved in the tarball generation (e.g. not using reproducible-builds-compliant gzip, tar/pax, and stabilizing all timezone and locale-related changes).

The openwrt buildbots did not yet get their major OS version updated, and are all based on exactly the same operating system, so this hindrance/bug is not being triggered in the official repositories and CI/CD pipeline. Yet. Hopefully Debian 9 -> Debian 10 doesn't trigger it, but if it does, it will be painful.