This PR:
- removes unused macros and duplicated code
- renames macros in a way, that makes the code self-descriptive.
This PR:
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
ACK 098d26d0cc00cb1bca005a0cd289f4cae753c67b
Built, run and tested on macOS Catalina 10.15.4
Perhaps let’s separate the pure-rename changes into another commit from the other changes? (I think the changes to share/genbuild.sh
are the only pure-rename ones). Also, is the DO_STRINGIZE
a mistake from before? Why is it not needed anymore?
Not quite sure how this mechanism works here, and wasn’t able to find a reference to it in the git-achive(1)
man page, could you point me in the right direction?
098d26d
Not quite sure how this mechanism works here, and wasn’t able to find a reference to it in the
git-achive(1)
man page, could you point me in the right direction?
a) we set the export-subst
attribute for src/clientversion.cpp
in the .gitattributes
file: https://github.com/bitcoin/bitcoin/blob/844d2070a2c0106bb7a54be5cad7d4da4d9cd55e/.gitattributes#L1
From the git docs:
If the attribute
export-subst
is set for a file then Git will expand several placeholders when adding this file to an archive. The expansion depends on the availability of a commit ID, i.e., ifgit archive
has been given a tree instead of a commit or a tag then no replacement will be done. The placeholders are the same as those for the option--pretty=format:
ofgit log
, except that they need to be wrapped like this:$Format:PLACEHOLDERS$
in the file. E.g. the string$Format:%H$
will be replaced by the commit hash.
b) $Format:%n#define GIT_COMMIT_ID "%H"$
has two placeholders:
%n
, which is expanded to a newline that makes a new uncommented LOC just after the comment that states the same thing :)0//! git will put "#define GIT_COMMIT_ID ..." on the next line inside archives.
%H
, which is expanded to a commit hashAlso, is the
DO_STRINGIZE
a mistake from before? Why is it not needed anymore?
It is still required: https://github.com/bitcoin/bitcoin/blob/844d2070a2c0106bb7a54be5cad7d4da4d9cd55e/src/clientversion.h#L17-L22
-BEGIN VERIFY SCRIPT-
sed -i 's/\bDESC\b/GIT_TAG/' share/genbuild.sh
sed -i 's/\bSUFFIX\b/GIT_COMMIT/g' share/genbuild.sh
-END VERIFY SCRIPT-
Updated 098d26d0cc00cb1bca005a0cd289f4cae753c67b -> 09ee167a6dd7b2d4ade828affc95a679acfaf6c6 (pr18616.02 -> pr18616.05, diff):
Code Review ACK 09ee167a6dd7b2d4ade828affc95a679acfaf6c6
Nit: personally, something like this in clientversion.cpp
made it a bit more readable for me without sacrificing the DRY-ness:
0#ifdef BUILD_GIT_TAG
1 #define BUILD_DESC BUILD_GIT_TAG
2#else
3 #define BUILD_BASE_DESC "v" STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) \
4 "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD)
5 #ifdef BUILD_GIT_COMMIT
6 #define BUILD_DESC BUILD_BASE_DESC "-" BUILD_GIT_COMMIT
7 #elif defined(GIT_COMMIT_ID)
8 #define BUILD_DESC BUILD_BASE_DESC "-g" GIT_COMMIT_ID
9 #else
10 #define BUILD_DESC BUILD_BASE_DESC "-unk"
11 #endif
12#endif
13
14const std::string CLIENT_BUILD(BUILD_DESC);
Updated 09ee167a6dd7b2d4ade828affc95a679acfaf6c6 -> c269e618cf53634d3cf270273ab1b0354dc3c119 (pr18616.05 -> pr18616.06, diff):