public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Achim Gratz <Stromeko@nexgo.de>
To: cygwin-apps@cygwin.com
Subject: Re: [ITA] cmake-3.18.0-1 and related packages
Date: Sat, 18 Jul 2020 10:13:29 +0200	[thread overview]
Message-ID: <87sgdp2qc6.fsf@Rainer.invalid> (raw)
In-Reply-To: <871rl9488v.fsf@Rainer.invalid> (Achim Gratz's message of "Sat, 18 Jul 2020 09:01:20 +0200")

Achim Gratz writes:
> Marco Atzeri via Cygwin-apps writes:
>> I know, but it take times, specially as I will hate to lose
>> the history if I port only last version
>
> You can rewrite the git repo with filter-branch to keep the history.  I
> did that with my packages since I also had them in a single repo.  I now
> have them as submodules in a new repo, although the submodules wouldn't
> strictly be necessary.

Here are a the scripts that I created for this conversion.  The first
one filters each subdirectory into its own branch.  The second one
imports one such branch into a new repo.  You need to define a cygpack:
alias in your gitconfig (global or local) to use it directly.  Obviously
you'll want to loop across all your packages, I did that directly in the
shell.  It goes without saying that you should do all operations on
fresh clones of your repositories so you can easily start over if
necessary.

The third script was for packages that I took over from Yaakov that he
had put earlier history on the Cygwin server (from Cygport, mostly) and
I had already local history fro my releases; it will fetch what's on
Cygwin and then append any local history.  If the relation is more
complicated than that you will either need to rewrite the history
manually or drop / branch off some of the intertwined history.

--8<- .gitconfig -cut here----------------start------------->8---
[url "git://cygwin.com/git/cygwin-packages"]
        InsteadOf = cygpack:
[url "ssh://cygwin@cygwin.com/git/cygwin-packages"]
        pushInsteadOf = cygpack:
--8<- .gitconfig -cut here----------------end--------------->8---

--8<- splitgit.dash -cut here--------------start------------->8---
#!/bin/dash
pkgs=""
spkg=""
if [ $# -gt 2 ] ; then
    orepo=$1; shift
    nrepo=$1; shift
    pkgs=$1; shift
    spkg=$pkgs
else
    echo "Not enough arguments!\n$@"
    exit 1
fi
while [ $# -gt 0 ] ; do
    pkgs="$pkgs $1"
    spkg="$spkg|$1"
    shift
done
echo "$spkg"
# clone repo and keep reference to original
git clone $orepo $nrepo
cd $nrepo
git branch unsplit master
# stuff packages into separate subdirectories
git filter-branch --index-filter ' \
      git ls-files -s | \
      perl -pE '"'"'s:\t('$spkg'):\t$1/$1:'"'"' | \
      env GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && \
      mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE" \
    ' HEAD
git branch subdirs
# split each subdir into a new branch
for pkg in $pkgs ; do
    git filter-branch -f --subdirectory-filter $pkg -- --all
    git branch $pkg
    git reset --hard  original/refs/heads/master
done
--8<- splitgit.dash -cut here-------------end--------------->8---

--8<- gitimport.dash -cut here------------start------------->8---
#!/usr/bin/dash
if [ $# -gt 1 ] ; then
    srepo=$(realpath $1); shift
    pkg=$1; shift
else
    echo "Not enough arguments!\n$@"
    exit 1
fi
echo "$pkg"
# create new git repo
git init $pkg
cd $pkg
# import history
git fetch -fu $srepo master:master
git reset --hard
git remote add origin cygpack:/$pkg
#
cd ..
--8<- gitimport.dash -cut here------------end--------------->8---

--8<- grafthist.dash -cut here------------start------------->8---
#!/bin/dash
if [ $# -gt 1 ] ; then
    srepo=$(realpath $1); shift
    pkg=$1; shift
else
    echo "Not enough arguments!\n$@"
    exit 1
fi
echo "$pkg"
# create new git repo
git clone git://cygwin.com/git/cygwin-packages/${pkg}.git || git init $pkg
cd $pkg
# import history
git fetch $srepo refs/heads/${pkg}:import
git checkout import
if [ "origin" = "$( git remote )" ] ; then
    # append imported history
    sha1=$( git show-ref refs/heads/master | cut -d\  -f 1 )
    echo $sha1
    git filter-branch -f \
      --commit-filter ' \
        if [ $# -eq 1 ] ; then \
          git commit-tree -p $( git show-ref refs/heads/master | cut -d" "  -f 1 ) $1 ; \
        else \
          git commit-tree "$@" ; \
        fi ' \
      --msg-filter ' \
        sed -e "s/initial commit/Take over maintenance/;s/^\* //" \
        ' \
      HEAD
fi
git branch -f master import
git reset --hard
cd ..
--8<- grafthist.dash -cut here------------end--------------->8---


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Samples for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra

  reply	other threads:[~2020-07-18  8:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17 20:14 Lemures Lemniscati
2020-07-17 21:13 ` Marco Atzeri
2020-07-18  1:00   ` Lemures Lemniscati
2020-07-18  6:12   ` Achim Gratz
2020-07-18  6:29     ` Marco Atzeri
2020-07-18  7:01       ` Achim Gratz
2020-07-18  8:13         ` Achim Gratz [this message]
2020-07-18 10:09         ` Lemures Lemniscati
2020-08-07 16:06           ` cmake upstream has merged cygwin patches Lemures Lemniscati
2020-08-07 19:51             ` Marco Atzeri
2020-08-08  0:47               ` Lemures Lemniscati
2020-08-10  8:17                 ` Marco Atzeri
2020-08-10 13:12                   ` Lemures Lemniscati
2020-11-19 22:45           ` cmake-3.19.0-1 and related packages Lemures Lemniscati
2020-11-25 22:11           ` cmake-3.19.1-1 " Lemures Lemniscati
2020-12-17 21:30           ` cmake-3.19.2-1 " Lemures Lemniscati
2021-03-27 15:58             ` Marco Atzeri
2021-03-27 22:02               ` Lemures Lemniscati
2021-03-28  2:45                 ` Lemures Lemniscati
2021-03-28  7:00                   ` Marco Atzeri
2021-03-28  0:12               ` Lemures Lemniscati
2021-03-28  7:02                 ` Marco Atzeri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sgdp2qc6.fsf@Rainer.invalid \
    --to=stromeko@nexgo.de \
    --cc=cygwin-apps@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).