Re: Need to change old commit (and regenerate tree)

5 messages, 4 authors, 2016-06-15 · open the first message on its own page

Re: Need to change old commit (and regenerate tree)

From: Andreas Schwab <hidden>
Date: 2016-06-15 22:48:50

Antriksh Pany [off-list ref] writes:
Instead of (what I initially expected):

A--------o--------o--------o--------o(old B)--------o--------o--------o(old C)

A2--------o--------o--------o--------B--------o--------o--------C


So what I am missing here? Aren't the new commits B~1, B~2, B~3
identical to C~4, C~5, C~6 (respectively) in all ways so as to have
gotten them the same SHA1 and hence appear as what I expected them to
appear?
No, they have a different commit time, which is also part of the hash.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

Re: Need to change old commit (and regenerate tree)

From: Jon Seymour <hidden>
Date: 2016-06-15 22:48:50

On Fri, May 21, 2010 at 8:09 AM, Andreas Schwab [off-list ref] wrote:
Antriksh Pany [off-list ref] writes:
quoted
Instead of (what I initially expected):

A--------o--------o--------o--------o(old B)--------o--------o--------o(old C)

A2--------o--------o--------o--------B--------o--------o--------C


So what I am missing here? Aren't the new commits B~1, B~2, B~3
identical to C~4, C~5, C~6 (respectively) in all ways so as to have
gotten them the same SHA1 and hence appear as what I expected them to
appear?
No, they have a different commit time, which is also part of the hash.
Of course, even if the commit time was forged to be the same, the
parent of B~3 is different to the parent of C~6 and since the parent
is also contributes bits to the respective hashes, B~3 will
necessarily (unlikely hash collisions excepted!) have a different hash
to C~6

jon.

Re: Need to change old commit (and regenerate tree)

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2016-06-15 22:48:50

On Fri, May 21, 2010 at 00:09, Andreas Schwab [off-list ref] wrote:
Antriksh Pany [off-list ref] writes:
quoted
Instead of (what I initially expected):

A--------o--------o--------o--------o(old B)--------o--------o--------o(old C)

A2--------o--------o--------o--------B--------o--------o--------C


So what I am missing here? Aren't the new commits B~1, B~2, B~3
identical to C~4, C~5, C~6 (respectively) in all ways so as to have
gotten them the same SHA1 and hence appear as what I expected them to
appear?
No, they have a different commit time, which is also part of the hash.
Indeed.

To avoid this, you have to:
  - rebase B on top of A2 first,

        git rebase --onto A2 A B

  - rebase of C on top of the new B.

        git rebase --onto B B_old C
       ("git rebase --onto B A C" should work too, as usually git is
smart enough to see
        that A-B_old is already applied. Use "git rebase --skip" if it isn't)

If A is an ancestor of A2, you can simplify to:

    git rebase A2 B
    git rebase B C

(Disclaimer: the examples without --onto I use almost daily, the ones
with I don't)

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

Re: Need to change old commit (and regenerate tree)

From: Antriksh Pany <hidden>
Date: 2016-06-15 22:48:50

Hi Jon

I guess the parent of both B~3 as well as C~6 is A2. So if, as you
say, the time can be made
identical, they should yield the same SHA1 IMHO.

On Fri, May 21, 2010 at 12:05 AM, Jon Seymour [off-list ref] wrote:
On Fri, May 21, 2010 at 8:09 AM, Andreas Schwab [off-list ref] wrote:
quoted
Antriksh Pany [off-list ref] writes:
quoted
Instead of (what I initially expected):

A--------o--------o--------o--------o(old B)--------o--------o--------o(old C)

A2--------o--------o--------o--------B--------o--------o--------C


So what I am missing here? Aren't the new commits B~1, B~2, B~3
identical to C~4, C~5, C~6 (respectively) in all ways so as to have
gotten them the same SHA1 and hence appear as what I expected them to
appear?
No, they have a different commit time, which is also part of the hash.
Of course, even if the commit time was forged to be the same, the
parent of B~3 is different to the parent of C~6 and since the parent
is also contributes bits to the respective hashes, B~3 will
necessarily (unlikely hash collisions excepted!) have a different hash
to C~6

jon.

Re: Need to change old commit (and regenerate tree)

From: Antriksh Pany <hidden>
Date: 2016-06-15 22:48:50

Thanks a lot.

I guess it is then not so straightforward to regenerate trees with
their relative structure
intact when an old commit changes. I was initially of the opinion that
it would be a trivial
rebasing of all branches from which the commit was reachable.
Apparently, not so.

On Fri, May 21, 2010 at 6:31 AM, Geert Uytterhoeven
[off-list ref] wrote:
On Fri, May 21, 2010 at 00:09, Andreas Schwab [off-list ref] wrote:
quoted
Antriksh Pany [off-list ref] writes:
quoted
Instead of (what I initially expected):

A--------o--------o--------o--------o(old B)--------o--------o--------o(old C)

A2--------o--------o--------o--------B--------o--------o--------C


So what I am missing here? Aren't the new commits B~1, B~2, B~3
identical to C~4, C~5, C~6 (respectively) in all ways so as to have
gotten them the same SHA1 and hence appear as what I expected them to
appear?
No, they have a different commit time, which is also part of the hash.
Indeed.

To avoid this, you have to:
 - rebase B on top of A2 first,

       git rebase --onto A2 A B

 - rebase of C on top of the new B.

       git rebase --onto B B_old C
      ("git rebase --onto B A C" should work too, as usually git is
smart enough to see
       that A-B_old is already applied. Use "git rebase --skip" if it isn't)

If A is an ancestor of A2, you can simplify to:

   git rebase A2 B
   git rebase B C

(Disclaimer: the examples without --onto I use almost daily, the ones
with I don't)

Gr{oetje,eeting}s,

                                               Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                                           -- Linus Torvalds
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help