Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 510704 - git-r3.eclass: support checkout of git repository by date
Summary: git-r3.eclass: support checkout of git repository by date
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Michał Górny
URL:
Whiteboard:
Keywords: NeedPatch
Depends on:
Blocks:
 
Reported: 2014-05-19 03:39 UTC by John (EBo) David
Modified: 2016-05-31 13:41 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Proposed patch (0001-git-r3.eclass-Support-checking-out-repo-by-date-5107.patch,4.62 KB, patch)
2016-05-26 12:10 UTC, Michał Górny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John (EBo) David 2014-05-19 03:39:35 UTC
I have a situation with building ebuilds that will be a pain to write in any way other than calling git.  Is it possible to support a EGIT_DATE which equates to something similar to:

  git checkout `git rev-list -n 1 --before="2009-07-27 13:37" master`

Where the date 2009-07-27 is passed in as a standard YYYYMMDD date-version string?

  Thanks and best regards,

  EBo --
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-05-25 17:30:09 UTC
Wouldn't --before fail at merge commits?
Comment 2 John (EBo) David 2016-05-26 06:39:12 UTC
To be honest I am not sure.  When I wrote this two years ago I think I was thinking of using a date==version string and querying git to supply the revision number/string so that I do not have to hard code it.  At the moment I have to explicitly give it (eg: 193acaa201efde6b358c2db5d1ffef35e436914e) instead of being able to resolve that via a date.  With something like the above I should be able to do version bumps to the ebuilds by simply changing the ebuild version number, and it is not exactly a "live" ebuild.  I should also mention that the upstream folks cannot be depended on tagging things in any useful way, and this was the best workaround I could think of.

So the question is if --before fail at merge commits. I am not sure.  I do not know enough of the git internals to hazard a guess.  That said we should be able to develop some unit tests and then test the current behaviour and open a discussion on what the expected and best behaviour would be.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-05-26 07:29:45 UTC
Just to be clear:

1. None of the git checkouts are considered 100% safe and suitable for release ebuilds in Gentoo. If you want a good and secure copy, make a snapshot that'll given proper checksum in the Manifest (SHA512).

2. The second-best choice is direct commit id since it gives SHA1-quality guarantee of matching commit. However, git does not support fetching by commit id directly, so we need to fetch the whole branch (and you need to specify an appropriate branch), and shallow clones are not supported.

3. Explicit tag has the advantage that it can be fetched remotely. However, upstream can update a tag and then the result would change. We could add some mechanism to ensure a specific commit id on a tag though.

4. Now, date is completely insecure and certainly not something that should be used in ebuilds. It could be useful for debugging though. Remember that:

a) there's no guarantee that commit dates are correct,

b) merge commits involve two or more branches evolving independently, so we have multiple states corresponding to the same date.

Which, long story short, means that at any point in time a particular date could start pointing to a completely different commit, due to a new merge commit or a regular commit with incorrectly set clock.
Comment 4 John (EBo) David 2016-05-26 07:56:15 UTC
I thought that when you merge, that the trunk only had only a single timeline.  I do see that each of the branches have their own, but that is why I specified 'master' in my example.

Regardless, I see that this may be problematic.  I mostly was using this for debugging purposes, and when the code stabilizes enough I bother to takign a snapshot (giving it some appropriate versioning).  That has truely been a pain when motoring through 40 different revisions...

Hmmmm... maybe this is not useful.  Take anything you find that is beneficial to the community and go ahead and close this ticket when you are ready.

Thanks!
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-05-26 11:31:01 UTC
I think passing --first-parent to rev-list solves the merge problem partially. At least as long as we follow the idea that first parent of merge is the 'old' state.
Comment 6 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-05-26 12:10:31 UTC
Created attachment 435460 [details, diff]
Proposed patch
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-05-26 12:11:25 UTC
I've been able to come up with this. It seems to work quite well, though it doesn't complain about invalid dates.
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-05-31 13:41:36 UTC
And merged.