Timeline for Why Git won't easily enable programs to output their version (commit hash)
Current License: CC BY-SA 4.0
20 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 22, 2019 at 12:50 | vote | accept | Niklas Rosencrantz | ||
| Nov 13, 2019 at 18:23 | comment | added | 8bittree | @NiklasRosencrantz Your solution does NOT put the commit id in the file. It puts the file's own blob hash into the file, i.e. it hashes the file's contents, and puts that resulting hash in. Technically, this is very similar to how CVS works, in that it is specific to the file (although, if two files have the same contents, they'll have the same blob hash, even if one was just created and the other has had hundreds of revisions), but it is not, as you say, the commit id. If you change and commit a different file, it will change the commit id, but have no effect on the hash in this file. | |
| Nov 8, 2019 at 7:15 | history | edited | Niklas Rosencrantz | CC BY-SA 4.0 |
edited body
|
| Nov 8, 2019 at 7:07 | comment | added | Doc Brown | @NiklasRosencrantz: did you notice, you can write an answer to your own question as an answer (and accept it), not just as part of your question. And yes, I understood perfectly what you meant, though your wording is pretty confusing (you don't want git to "generate a plain-text file in the repository with the latest commit hash string in a list", you want a keyword substitution feature which can replace a placeholder in a source file by the latest commit hash string). | |
| Nov 8, 2019 at 5:52 | answer | added | kiwiron | timeline score: 2 | |
| Nov 8, 2019 at 4:01 | comment | added | Niklas Rosencrantz | @Euphoric Because when doing a release of a new version, it can be important to quickly see exactly what has changed i.e. what is the diff between this release and the previous, and even more fundamental to actually verify that the new release actually is running and that it is not still the old release/version. Seeing the diff between two commits is easy but only if you have the two commit ids. So we need a way to get the commit ids from running project that have been released so that we can match the running app with actual versions of the source code. I updated my answer with a method now. | |
| Nov 8, 2019 at 3:43 | history | edited | Niklas Rosencrantz | CC BY-SA 4.0 |
added 470 characters in body
|
| Nov 8, 2019 at 3:08 | history | edited | Niklas Rosencrantz | CC BY-SA 4.0 |
added 270 characters in body
|
| Nov 8, 2019 at 3:07 | comment | added | Niklas Rosencrantz |
@DocBrown I think what I was looking for is described in this answer. I could make it work as described by adding the .gitattributes file and then the $Id$ will work just like is did in CVS.
|
|
| Nov 7, 2019 at 15:48 | comment | added | Doc Brown | @Euphoric: the OP most probably gave a slightly wrong description - I guess he means "generate a plain-text file in the working directory, from the repo", not "in the repository". That is what causing the confusion here. So this is not about "running programs in the repo". | |
| Nov 7, 2019 at 14:43 | comment | added | Dan Wilson |
Would it not be a simple feature of git... I think the obvious answer is that Git already provides enough extension points for you to accomplish this yourself. Git has been successful by focusing on its core competencies.
|
|
| Nov 7, 2019 at 13:58 | comment | added | neilsimp1 |
To me, a commit hash and the version of the software are two different things. You might tag commit abc12345 as version 2.0, but I don't know that anybody besides developers cares about the commit hash over seeing version 2.0 in Help->About.
|
|
| Nov 7, 2019 at 13:58 | comment | added | Jörg W Mittag |
Is there anything you are missing from git describe? It is guaranteed to be unique and monotonically increasing, provided you have a sane tagging strategy.
|
|
| Nov 7, 2019 at 13:51 | comment | added | Mike Partridge | Git is a general purpose version control system, so while it's widely used in software development, this feature wouldn't be core to its function. | |
| Nov 7, 2019 at 13:43 | comment | added | Euphoric | Again. Why do you believe the program will run from git repository? Last time I checked, 99.99% of all software runs outside it's repository. That means that the information has to be put there during compilation. And compiler can put that there by simply calling git status. | |
| Nov 7, 2019 at 13:40 | comment | added | Simon B | @Euphoric Yes, it's a useful thing to have. It means that a "Help->About" dialog can tell you the exact version of the software. Even the venerable SCCS from 1972 could to it. | |
| Nov 7, 2019 at 13:40 | review | Close votes | |||
| Nov 14, 2019 at 3:05 | |||||
| Nov 7, 2019 at 13:31 | comment | added | Euphoric | Why do you assume this is a common problem? I don't claim long experience in SW development. But I never ever used that kind of information. Also, why do you believe running programs right from git repository is common? | |
| Nov 7, 2019 at 13:20 | comment | added | Doc Brown | See Git keyword substitution like those in Subversion?, this should basically provide what you are looking for. | |
| Nov 7, 2019 at 13:08 | history | asked | Niklas Rosencrantz | CC BY-SA 4.0 |