All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Maaartin-1 <grajcar1@seznam.cz>
Cc: Jonathan Nieder <jrnieder@gmail.com>,
	git@vger.kernel.org, Aleksey Shumkin <zapped@mail.ru>
Subject: Re: [RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for
Date: Fri, 14 Jan 2011 23:48:30 +0100	[thread overview]
Message-ID: <201101142348.31647.jnareb@gmail.com> (raw)
In-Reply-To: <4D308B69.1050003@seznam.cz>

On Fri, 14 Jan 2011, Maaartin-1 wrote:
> On 11-01-14 09:49, Jonathan Nieder wrote:
> > Some tweaks suggested by Maaartin:
> 
> [snip]
> 
>> [side note: please do not prune the cc list; I only stumbled on this
>> message in the online archive by luck]
> 
> What could I have done about it? I didn't received it by email and
> answered using post.gmane.org. There's no way to add CC there. If I'd
> wrote an email instead, it wouldn't be placed in the thread.

In a good newsreader, like e.g. Gnus from GNU Emacs, you have option
to do 'reply all via email', which includes also git@vger.kernel.org,
i.e. mailing list from which gmane newsgroup is created.  That's what
I do nowadays (usually).

> [snip]
> 
>>>> +<1> Find all parentless commits in the 'master' branch;
>>>> +for 'master' read the branch holding v2.5 history.
>>>
>>> Aren't you later calling it "FIRST" and assuming there's only one?
>> 
>> Hmm.  I want to say that there _could_ be multiple parentless commits
>> in the v2.5 history and we are treating one of them as its root (just
>> like git master has multiple parentless ancestors but e83c5163 is
>> conventionally considered its beginning).  Not sure how to write that
>> clearly.
> 
> Maybe just something like "Let's assume there's only one and let's call
> it FIRST". For the example, this is enough.

That might be good enough, as I don't think that at beginning (where you
are creating current and archive repository) one would have multiple roots
from joining separate projects.
 
>>> Isn't the combination of "-i" (=in-place edit) with redirection wrong?
>> 
>> Good catch (the "-i" is a typo).
> 
> I'd go the other way round and use "-i" so I'd need only one file. Using
> a shell variable instead would be even better, s. below.

No, using shell variable for storing commit object is *not* a good idea.
Either save it to temporary file, where you can edit it using editor of
your choice, or use pipeline.
 
> [snip]
> 
> I tried to use the vars instead of files below, but never tested it. I
> used "first_commit" instead of both "tmp" and "new", which is not really
> nice.
> 
>> +$ git rev-list master --parents | grep -v ' '
>> +$ first=$(git rev-list master --parents | grep -v ' ') <1>

Or using always the oldest commit:

   +$ first=$(git rev-list master --date-order --parents | grep -v ' ' | tail -1) <1>


>> +$ git rev-parse v2.4                                   <2>

Let's save it to a variable too

   +$ join=$(git rev-parse v2.4)                           <2>


>> +$ git cat-file commit $first >tmp                      <3>

We can use COMMIT, or even FIRST as a file name here.

> $ first_commit = $(git cat-file commit FIRST)            <3>

No.  Just... no.

> > +$ sed "/^tree / a \\
> > +parent $(git rev-parse v2.4)" <tmp >new                <4>
> 
> $ first_commit = $($ echo $first_commit |
> sed  "/^tree / a \\
> parent $(git rev-parse v2.4)")                      <4>
> 
> Unfortunately, the line got too long. For sed unaware people like me it
> may not be obvious that a line break is required.

No, it is not required, I think.

> I'd use perl, anyway. 
> 
> $ first_commit = $($ echo $first_commit |
> perl -p
> "s/^tree .*/$&\nparent $(git rev-parse v2.4)/")      <4>
> 
> > +$ new_commit=$(git hash-object -t commit -w new)       <5>
> 
> $ new_commit=$(echo $first_commit |
> git hash-object -t commit -w --stdin)       <5>

If you don't use temporary file, which you can edit, you can use pipeline
instead:

  $ new_commit=$(git cat-file commit $first_commit |
                 sed -e "/^tree / a\\parent $(git rev-parse v2.4)" |
                 git hash-object -t commit -w --stdin

  $ git replace $first_commit $new_commit

-- 
Jakub Narebski
Poland

  parent reply	other threads:[~2011-01-14 22:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11 10:41 Merge two different repositories (v2.4 + v2.5) into the one (v2.4 -> v2.5). Possible? Алексей Шумкин
2011-01-11 11:49 ` "Martin Krüger"
2011-01-11 12:33   ` Re[2]: " Алексей Шумкин
2011-01-11 12:41     ` Andreas Ericsson
2011-01-11 14:58       ` Re[2]: " Алексей Шумкин
2011-01-11 12:47     ` "Martin Krüger"
2011-01-11 13:21 ` Jakub Narebski
2011-01-11 14:49   ` Re[2]: " Алексей Шумкин
2011-01-11 15:16   ` Алексей Шумкин
2011-01-12  0:08   ` [RFC/PATCH] Documentation: start to explain what git replace is for Jonathan Nieder
2011-01-12 22:47     ` Maaartin
2011-01-13  7:52       ` Alexey Shumkin
2011-01-14  8:49       ` [RFC/PATCH 2/1] fixup! " Jonathan Nieder
2011-01-14 17:44         ` Maaartin-1
2011-01-14 19:30           ` Jonathan Nieder
2011-01-14 21:09             ` how multiple roots happen (Re: [RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for) Jonathan Nieder
2011-01-14 22:48           ` Jakub Narebski [this message]
2011-01-15  0:04             ` [RFC/PATCH 2/1] fixup! Documentation: start to explain what git replace is for Maaartin-1

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=201101142348.31647.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=grajcar1@seznam.cz \
    --cc=jrnieder@gmail.com \
    --cc=zapped@mail.ru \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.