git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* how to reorder commits
@ 2009-07-20 15:07 Rustom Mody
  2009-07-20 15:37 ` Santi Béjar
  2009-07-20 21:27 ` Daniel Barkalow
  0 siblings, 2 replies; 6+ messages in thread
From: Rustom Mody @ 2009-07-20 15:07 UTC (permalink / raw
  To: git

I have a sequence of commits. I tried to reorder the top two in this way.
$ git rebase -i HEAD^^

flip the two pick lines and exit vi

I find my file full of conflict markers.
So what is the way of doing:
HEAD becomes current HEAD^
HEAD^ becomes current HEAD
without having to handle conflicts ??

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to reorder commits
  2009-07-20 15:07 how to reorder commits Rustom Mody
@ 2009-07-20 15:37 ` Santi Béjar
  2009-07-20 16:01   ` Rustom Mody
  2009-07-20 21:27 ` Daniel Barkalow
  1 sibling, 1 reply; 6+ messages in thread
From: Santi Béjar @ 2009-07-20 15:37 UTC (permalink / raw
  To: Rustom Mody; +Cc: git

2009/7/20 Rustom Mody <rustompmody@gmail.com>:
> I have a sequence of commits. I tried to reorder the top two in this way.
> $ git rebase -i HEAD^^
>
> flip the two pick lines and exit vi
>
> I find my file full of conflict markers.

"git rebase" applies the changes between the commit and the parent,
and if the changes have conflicts this is what you get.

> So what is the way of doing:
> HEAD becomes current HEAD^
> HEAD^ becomes current HEAD

$ git branch old
$ git reset --hard HEAD~2
$ git read-tree old
$ git commit -C old
$ git read-tree old^
$ git commit -C old^

But normally you reorder "changes", not trees.

HTH,
Santi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to reorder commits
  2009-07-20 15:37 ` Santi Béjar
@ 2009-07-20 16:01   ` Rustom Mody
  2009-07-20 16:16     ` Santi Béjar
  0 siblings, 1 reply; 6+ messages in thread
From: Rustom Mody @ 2009-07-20 16:01 UTC (permalink / raw
  To: git

On Mon, Jul 20, 2009 at 9:07 PM, Santi Béjar<santi@agolina.net> wrote:
> 2009/7/20 Rustom Mody <rustompmody@gmail.com>:
>> I have a sequence of commits. I tried to reorder the top two in this way.
>> $ git rebase -i HEAD^^
>>
>> flip the two pick lines and exit vi
>>
>> I find my file full of conflict markers.
>
> "git rebase" applies the changes between the commit and the parent,
> and if the changes have conflicts this is what you get.
>
>> So what is the way of doing:
>> HEAD becomes current HEAD^
>> HEAD^ becomes current HEAD
>
> $ git branch old
> $ git reset --hard HEAD~2
> $ git read-tree old
> $ git commit -C old
> $ git read-tree old^
> $ git commit -C old^

Beautiful -- plumbing is nifty!

>
> But normally you reorder "changes", not trees.

Which may not always be conflict-free?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to reorder commits
  2009-07-20 16:01   ` Rustom Mody
@ 2009-07-20 16:16     ` Santi Béjar
       [not found]       ` <873a8r132o.fsf@krank.kagedal.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Santi Béjar @ 2009-07-20 16:16 UTC (permalink / raw
  To: Rustom Mody; +Cc: git

2009/7/20 Rustom Mody <rustompmody@gmail.com>:
> On Mon, Jul 20, 2009 at 9:07 PM, Santi Béjar<santi@agolina.net> wrote:
>> But normally you reorder "changes", not trees.
>
> Which may not always be conflict-free?

No. But the fact that there is no porcelain way to do it may show that
reordering trees is not what you normally want, even if reordering
trees is conflict-free.

HTH,
Santi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to reorder commits
  2009-07-20 15:07 how to reorder commits Rustom Mody
  2009-07-20 15:37 ` Santi Béjar
@ 2009-07-20 21:27 ` Daniel Barkalow
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Barkalow @ 2009-07-20 21:27 UTC (permalink / raw
  To: Rustom Mody; +Cc: git

On Mon, 20 Jul 2009, Rustom Mody wrote:

> I have a sequence of commits. I tried to reorder the top two in this way.
> $ git rebase -i HEAD^^
> 
> flip the two pick lines and exit vi
> 
> I find my file full of conflict markers.
> So what is the way of doing:
> HEAD becomes current HEAD^
> HEAD^ becomes current HEAD
> without having to handle conflicts ??

Note that what you're asking for here would add both changes in HEAD^ and 
*remove* some changes in HEAD (to get to the state where only the change 
that was made first has been made).

What you tried with rebase is correct, but if your changes in those 
commits intersect, impossible to do automatically:

Original:

 This is an example.

Change 1:

-This is an example.
+This is a better example.

Change 2:

-This is a better example.
+This is a better sentence.

Now, make change 2 without change 1. Even if you can split the changes as
(1) "an"->"a better"; (2) "example"->"sentence", you get:

 This is an sentence.

When the correct version would be:

 This is a sentence.

But there's no automated way to know this, so you get conflict markers.

	-Daniel
*This .sig left intentionally blank*

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: how to reorder commits
       [not found]       ` <873a8r132o.fsf@krank.kagedal.org>
@ 2009-07-21  7:53         ` Rustom Mody
  0 siblings, 0 replies; 6+ messages in thread
From: Rustom Mody @ 2009-07-21  7:53 UTC (permalink / raw
  To: Git Mailing List

On Tue, Jul 21, 2009 at 2:31 AM, David Kågedal<david@kagedal.org> wrote:
>
> Latest stgit actually has it. You can push a patch with the --set-tree
> flag. So your sequence of commands would have been (with the latest
> two commits as stg patches called "old" and "older")
>
> $ stg series
... example snipped ...

Thanks for the info but I gather that stgit does not run on windows?
I need git to run on both on linux and windows.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-07-21  7:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-20 15:07 how to reorder commits Rustom Mody
2009-07-20 15:37 ` Santi Béjar
2009-07-20 16:01   ` Rustom Mody
2009-07-20 16:16     ` Santi Béjar
     [not found]       ` <873a8r132o.fsf@krank.kagedal.org>
2009-07-21  7:53         ` Rustom Mody
2009-07-20 21:27 ` Daniel Barkalow

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).