File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -30,3 +30,6 @@ const char* git_Describe() {
3030const char* git_Branch() {
3131 return "@GIT_BRANCH@";
3232}
33+ const char* git_CommitShort() {
34+ return "@GIT_SHORT@";
35+ }
Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ const char* git_Describe();
5252// / The symbolic reference tied to HEAD.
5353const char * git_Branch ();
5454
55+ // / The commit short SHA1.
56+ const char * git_CommitShort ();
57+
5558GIT_VERSION_TRACKING_EXTERN_C_END
5659#undef GIT_VERSION_TRACKING_EXTERN_C_BEGIN
5760#undef GIT_VERSION_TRACKING_EXTERN_C_END
@@ -143,6 +146,10 @@ inline const StringOrView Branch() {
143146 static const StringOrView kValue = internal::InitString (git_Branch ());
144147 return kValue ;
145148}
149+ inline const StringOrView CommitShort () {
150+ static const StringOrView kValue = internal::InitString (git_CommitShort ());
151+ return kValue ;
152+ }
146153
147154} // namespace git
148155
Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ set(_state_variable_names
105105 GIT_COMMIT_BODY
106106 GIT_DESCRIBE
107107 GIT_BRANCH
108+ GIT_SHORT
108109 # >>>
109110 # 1. Add the name of the additional git variable you're interested in monitoring
110111 # to this list.
@@ -242,6 +243,14 @@ function(GetGitState _working_dir)
242243 set (ENV{GIT_BRANCH} "${output} " )
243244 endif ()
244245
246+ # Get output of git describe
247+ RunGitCommand(rev-parse --short ${object} )
248+ if (NOT exit_code EQUAL 0)
249+ set (ENV{GIT_SHORT} "unknown" )
250+ else ()
251+ set (ENV{GIT_SHORT} "${output} " )
252+ endif ()
253+
245254 # >>>
246255 # 2. Additional git properties can be added here via the
247256 # "execute_process()" command. Be sure to set them in
You can’t perform that action at this time.
0 commit comments