* Support with finding git objects
@ 2024-03-01 19:06 Ayoub, Toufic
2024-03-04 10:34 ` brian m. carlson
0 siblings, 1 reply; 2+ messages in thread
From: Ayoub, Toufic @ 2024-03-01 19:06 UTC (permalink / raw)
To: git@vger.kernel.org
Hello everyone,
Hope this message finds you. I need your support regarding an issue my team is facing.
We have a code in our SW which shall display the date of the git commit. There is a path in the code that if it is executed on a platform where git is not installed, that this commit date shall be found by looking at:
1. Reading from HEAD file the commit hash
2. Searching for this commit hash under .git/objects
The problem we are facing is that sometimes, when the default master branch is updated with the newest commit, this commit will not be found locally, even after doing git pull and so on...
The commit can be found with:
1. git log
2. git cat-file -t <commit hash> -> it returns "commit"
3. git reflog
but the strange thing is that we can neither find it under .git/objects/ nor under .git/objects/pack (although that is the newest commit and shall not be packed).
Can you please provide support by:
1. telling me it that is an issue or is it expected?
2. If that is expected, where shall we find this commit object to retrieve the commit message and date from it (without running git commands)?
3. Or recommending me some other solution
I would appreciate that.
Best regards,
Toufic Ayoub
Software Developer
Hemodynamic Algorithms
Hospital Patient Monitoring
Philips
Philips Medizin Systeme Böblingen GmbH, Hewlett-Packard-Strasse 2, 71034 Boeblingen, Germany
Email toufic.ayoub@philips.com |www.philips.com/healthcare
Geschäftsführer: Dr. Dieter Haase (Sprecher), Günter Gegner, Sang Do Kim, Florian Kuhn
Registergericht Stuttgart Reg.-Nr. HRB 245187, Sitz der Gesellschaft: Böblingen
Simply switch to printing double-sided and printing less.
________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Support with finding git objects
2024-03-01 19:06 Support with finding git objects Ayoub, Toufic
@ 2024-03-04 10:34 ` brian m. carlson
0 siblings, 0 replies; 2+ messages in thread
From: brian m. carlson @ 2024-03-04 10:34 UTC (permalink / raw)
To: Ayoub, Toufic; +Cc: git@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 2800 bytes --]
On 2024-03-01 at 19:06:29, Ayoub, Toufic wrote:
> Hello everyone,
Hey,
> Hope this message finds you. I need your support regarding an issue my team is facing.
> We have a code in our SW which shall display the date of the git commit. There is a path in the code that if it is executed on a platform where git is not installed, that this commit date shall be found by looking at:
> 1. Reading from HEAD file the commit hash
> 2. Searching for this commit hash under .git/objects
> The problem we are facing is that sometimes, when the default master branch is updated with the newest commit, this commit will not be found locally, even after doing git pull and so on...
> The commit can be found with:
> 1. git log
> 2. git cat-file -t <commit hash> -> it returns "commit"
> 3. git reflog
>
> but the strange thing is that we can neither find it under .git/objects/ nor under .git/objects/pack (although that is the newest commit and shall not be packed).
I think you're maybe making some assumptions about when loose objects
are and are not created that Git doesn't guarantee. For example, if
you're doing a `git pull` or `git fetch`, it is entirely possible that
the objects downloaded remain in a pack. In fact, by default, Git will
leave large fetches as packs to avoid an explosion of loose objects.
Note that the name of a pack is based on the hash of the entire pack
contents, not based on the items it contains (although obviously those
influence the pack contents).
> Can you please provide support by:
> 1. telling me it that is an issue or is it expected?
I believe this is expected.
> 2. If that is expected, where shall we find this commit object to retrieve the commit message and date from it (without running git commands)?
Sorry, but you're going to need to use Git commands to do this. You
could also use libgit2, but that doesn't work with SHA-256 repositories
or certain other features.
> 3. Or recommending me some other solution
I assume that you're building this software on a machine that _does_
have Git, so you could generate a file during the build process that
includes the commit date, commit hash, and any other information you
want. This is easy to do for compiled languages, but it's also possible
to generate something like a version.rb file for Ruby or the like as
part of your build process.
In the interests of reproducible builds, you will of course want to use
the commit metadata and not the actual timestamp of building.
If that doesn't work for you, maybe you could tell us a little bit about
your goal with this process and what you're using it for, and we can
help you more then.
--
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-04 10:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01 19:06 Support with finding git objects Ayoub, Toufic
2024-03-04 10:34 ` brian m. carlson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox