Re: Preserving git history across repositories

[email protected] (James E Keenan)
Newsgroups perl.cpan.workers
Message-ID <[email protected]>
On 12/29/13 5:30 AM, Aristotle Pagaltzis wrote:
> * James E Keenan<[email protected]>  [2013-12-28 19:15]:
>> At this point, the top-level directory merely contained the
>> directories formerly found in ext/Pod-Html/. And 'git log' and 'git
>> blame' indicated that the history had been preserved.
>
> Except, at one time it had lived in lib/ and you are completely missing
> that history. Yours effectively starts at the point where Nick moved it:
> https://github.com/jkeenan/opodhtml/commit/75e62e6c1c6203daf034df38b525a6428d419b19
> But you then have a couple of commits before that, at the beginning of
> your local history… which are completely empty.
>
>> git filter-branch --subdirectory-filter ext/Pod-Html/ -- --all
>
> So first, make sure there are no useless commits:
>
>      git filter-branch --prune-empty \
>          --subdirectory-filter ext/Pod-Html/ -- --all
>
> Next, you REALLY don’t want --all, which makes some 63 THOUSAND commits
> that will take forEVER to process (hours). You want to look at only the
> commits that touch relevant paths, which is some 530 total. On an SSD
> that can be index-filtered in half a minute. MUCH better.
>
>      git filter-branch --prune-empty \
>          --subdirectory-filter ext/Pod-Html/ -- -- lib/Pod ext/Pod-Html
>
> Note the double `--` – that is not a typo, the first `--` is for telling
> git-filter-branch that the rest of the arguments are for git-rev-list,
> so the second one gets passed through to git-rev-list, which takes it to
> mean that only paths follow.
>
> Next, since unfortunately --subdirectory-filter cannot extract multiple
> directories at once, this job will need --index-filter.
>
>      git filter-branch --prune-empty --index-filter '
>          git rm --cached -r -q -- . ;
>          git reset -q $GIT_COMMIT -- ext/Pod-Html/ lib/Pod/
>      ' -- -- ext/Pod-Html/ lib/Pod/
>
> The first line will clear out the index entirely. The next line restores
> the relevant directories from the original commit undergoing rewriting.
>
> Now comes the hard part, because lib/Pod/ alone is both too much (there
> have been a number of other modules in there over time) as well as too
> little (the relevant files used to be strewn all over the place before
> there were consolidated into ext/Pod-Html/). This requires sleuthing.
> I started with a full clone of perl5.git and did
>
>      git log --name-status --full-diff -- ext/Pod-Html | egrep ^R
>
> to find out all the files that were ever moved into ext/Pod-Html from
> elsewhere:
>
>      lib/Pod/Html.pm
>      lib/Pod/t/eol.t
>      lib/Pod/t/htmlescp.pod
>      lib/Pod/t/htmlescp.t
>      lib/Pod/t/htmllink.pod
>      lib/Pod/t/htmllink.t
>      lib/Pod/t/htmlview.pod
>      lib/Pod/t/htmlview.t
>      lib/Pod/t/pod2html-lib.pl
>      pod/pod2html.PL
>
> That’s not necessarily sufficient since those files may have chequered
> histories of their own that may need tracking. E.g. it turns out that
> pod/pod2html.PL had a predecessor called pod/pod2html.SH very early on,
> which had been called pod/pod2html before even that. Are they relevant?
> Maybe. In this case it turns out the answer is yes: they were not actual
> shell scripts, but wrappers that generated a Perl pod2html script whose
> code became the installed pod2html became the module plus stub script…
> so you don’t want to miss them.
>
> The other files turn out to be boring and obvious. (Thankfully!)
>
> A potential complication is that Pod::Html used to load Pod::Functions.
> But it turns out that it never actually used anything from that module…
> as far as I can tell. So I’d take the easy way out: simply ignore that.
>
> In the final analysis, you get this:
>
>      export L='ext/Pod-Html/ lib/Pod/Html.pm ...' # all the files listed above
>      git filter-branch --prune-empty --index-filter '
>          git rm --cached -r -q -- . ;
>          git reset -q $GIT_COMMIT -- $L
>      ' -- -- $L
>
> This extracts 287 commits from perl5.git, including the far beginning of
> history. It leaves everything in the subdirectories it was in while it
> was in perl5.git, but I figure that’s better here since the history of
> splits and moves among files becomes unintelligible otherwise.
>
> I’ve put up the result:
>
>      https://github.com/ap/opodhtml
>
> Feel free to clone that as a basis for the rest of your work.
>
> I figure a commit that moves ext/Pod-Html/* to the root of the repo is
> a clean cut to document “today begins the rest of life for this module”.
> I have not done this, figuring I’ll leave it to you to do the honours.
>
> (I want to get rid of that repo once it has served its purpose so please
> let me know either way. If you do choose to use it, ideally, do not fork
> it on GitHub (since that would record it as a fork), just git-clone it,
> change the origin URL in to your existing GH repo, and force-push.)
>

Aristotle,

Thanks for the git work; it's years beyond my own git fu and that of 
almost everyone I know.

Can you check out that the 'master' branch at 
https://github.com/jkeenan/opodhtml has the correct history?

Thank you very much.
Jim Keenan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.