newline problem with genVersionHeader.pl
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
New
|
Undecided
|
Unassigned |
Bug Description
After merging the current EPICS 7.0 branch into my PSI branch, I got a generated epicsVCS.h header file with invalid syntax on RHEL7 (but not on RHEL8):
#ifndef EPICS_VCS_
#define EPICS_VCS_
"
Note the newline within the string.
I tracked that down to a strange behavior of git show in git version 1.8.3.1 as installed by default on RHEL7:
Whenever the current commit is a merge, then the output of 'git show -s --format=%ci' (as used by genVersionHeade
Piping it to hexdump show the issue:
$git co 7.0
git show -s --format=%ci | hexdump -C
00000000 32 30 32 33 2d 30 33 2d 31 30 20 31 32 3a 30 32 |2023-03-10 12:02|
00000010 3a 32 39 20 2b 30 30 30 30 0a |:29 +0000.|
0000001a
Just as it should be.
Now check out a merge commit:
$git co e63184e
[...]
HEAD is now at e63184e... Merge PR #63, longout.OOPT
$ git show -s --format=%ci | hexdump -C
00000000 32 30 32 32 2d 31 32 2d 32 39 20 31 36 3a 33 31 |2022-12-29 16:31|
00000010 3a 34 32 20 2d 30 36 30 30 0a 0a |:42 -0600..|
0000001b
Note the extra 0a!
This extra newline gets pasted into epicsVCS.h.
BTW: Git version 2.31.1 as installed by default on RHEL8 does not show this bug.
Of course one could blame the problem on the old git version, but I think just to be on the safe side, it would be better to remove all terminating newlines (and returns, maybe all whitespace) and not only the last one, as perl seems to do.
PS: The bug in git show can be reproduced even without checking out the commit:
git show -s --format=%ci e63184e
The extra newline does not depend on the format. Even plain 'git show COMMIT' shows one newline too many whenever the COMMIT is a merge.