threads / bug / 51482

[BUG] Branches before "git subtree add --squash" are pushed via "git subtree push"

Subject: [BUG] Branches before "git subtree add --squash" are pushed via "git subtree push"

## tl;dr

2 messages between Jul 15, 2019 and Aug 14, 2020.

replies: 1people: 1as markdown or json

Danny Lin· Jul 15, 2019, 18:30 UTC · lore
Say we have a repository with "master" and "sub" branches like below:
    A---B---C---D---E---F  master
               /
          X---Y
    X---Y  sub

where commits A and B include changes in subdirectory "sub", commit C removes subdirectory "sub", commit D is generated by "git subtree add -P sub Y", and commits E and F also include changes in subdirectory "sub".

We'd get this if we run "git subtree push -P sub . sub" on master at F:
    X---Y---E'--F'  sub (after push)

On the other hand, if we have simliar trees except that commit D is generated by "git subtree add --squash -P sub Y":

    A---B---C---D---E---F  master
               /
              Y'
    X---Y  sub

We'd expect to get this when we run "git subtree push -P sub . sub" on master at F:

    X---Y---E'--F'  sub (after push, expected)
But actually we get this (in Git 2.22.0):
    A---B---C---D'--E'--F'  sub (after push, actual)
               /
          X---Y

This seems to be a side effect of 2.7.0 -> 2.7.1 in which a change is made to include merged branches in "git subtree push", but mistakenly causes branches before "git subtree add --squash" be included.

Danny Lin· Aug 14, 2020, 16:28 UTC · re: Danny Lin · lore

Re: [BUG] Branches before "git subtree add --squash" are pushed via "git subtree push"

Sadly no one cares about this issue... This bug is especially obvious if we simply run `git subtree push` after a `git subtree add --squash`:

If master is at commit D, which is generated by `git subtree add --squash -P sub Y`:

    A---B---C---D  master
               /
              Y'
    X---Y  sub
After running `git subtree push -P sub . sub`, we get:
    A---B---C---D'  sub (after push, actual)
               /
          X---Y
While the sub branch should not change at all!

This bug, seemingly introduced by 933cfeb90b5d03b4096db6d60494a6eedea25d03 critically makes --squash approach for `git subtree` almost unusable. Added related developers to CC list for better notice.

Show 41 quoted lines
>
> Say we have a repository with "master" and "sub" branches like below:
>
>     A---B---C---D---E---F  master
>                /
>           X---Y
>
>     X---Y  sub
>
> where commits A and B include changes in subdirectory "sub", commit C
> removes subdirectory "sub", commit D is generated by "git subtree add
> -P sub Y", and commits E and F also include changes in subdirectory
> "sub".
>
> We'd get this if we run "git subtree push -P sub . sub" on master at F:
>
>     X---Y---E'--F'  sub (after push)
>
> On the other hand, if we have simliar trees except that commit D is
> generated by "git subtree add --squash -P sub Y":
>
>     A---B---C---D---E---F  master
>                /
>               Y'
>
>     X---Y  sub
>
> We'd expect to get this when we run "git subtree push -P sub . sub" on
> master at F:
>
>     X---Y---E'--F'  sub (after push, expected)
>
> But actually we get this (in Git 2.22.0):
>
>     A---B---C---D'--E'--F'  sub (after push, actual)
>                /
>           X---Y
>
> This seems to be a side effect of 2.7.0 -> 2.7.1 in which a change is
> made to include merged branches in "git subtree push", but mistakenly
> causes branches before "git subtree add --squash" be included.

← back to recent threads