git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Lodato <lodatom@gmail.com>
To: Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>, git list <git@vger.kernel.org>
Subject: Re: Announcing git-reparent
Date: Mon, 14 Jan 2013 15:28:23 -0500	[thread overview]
Message-ID: <CAHREChigPiRpwcM5QPEG8UJVro_fTN_a76AZaqowTWbwtw_M-g@mail.gmail.com> (raw)
In-Reply-To: <CAA01Csoh24ppo37fzptzZKvFrzGQyhz-0eDTQsP8tZiTRQ2YwA@mail.gmail.com>

On Mon, Jan 14, 2013 at 3:03 AM, Piotr Krukowiecki
<piotr.krukowiecki@gmail.com> wrote:
> Just wondering, is the result different than something like
>
> git checkout commit_to_reparent
> cp -r * ../snapshot/
> git reset --hard new_parent
> rm -r *
> cp -r ../snapshot/* .
> git add -A
>
> (assumes 1 parent, does not cope with .dot files, and has probably
> other small problems)

The result is similar, but your script would also lose the commit
message and author.  I think the following would do exactly as my
script does (untested):

git checkout commit_to_reparent
git branch tmp
git reset --soft new_parent
git commit -C tmp
git branch -D tmp

I actually contemplated using the above method in my script, rather
than git-commit-tree and git-reset.  In the end, I decided to stick
with my original approach because it does not create any intermediate
state; either an early command fails and nothing changes, or the git
reset works and everything is done.  Using the above might be cleaner
for the --edit flag since it allows the git-commit cleanup of the
commit message, but this would require much more careful error
handling, and might make the reflog uglier.

I'd be interested to hear a git expert's opinion on the choice.

  parent reply	other threads:[~2013-01-14 20:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-14  6:15 Announcing git-reparent Mark Lodato
2013-01-14  7:16 ` Jonathan Nieder
2013-01-14  8:03   ` Piotr Krukowiecki
2013-01-14 20:08     ` Andreas Schwab
2013-01-14 20:28     ` Mark Lodato [this message]
2013-01-14  8:05   ` Junio C Hamano

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=CAHREChigPiRpwcM5QPEG8UJVro_fTN_a76AZaqowTWbwtw_M-g@mail.gmail.com \
    --to=lodatom@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=piotr.krukowiecki@gmail.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 NNTP newsgroup(s).