Skip to main content

Scenario: moved-with-unpushed-commits

A splice with an unpushed commit is moved with git mv. The next push sends the right content, but squashes the unpushed commit into the move: its message and author are lost. This is a known bug, #4.

  • Monorepo (vendor/a/): cloned at seed, then a local commit, local change, not pushed yet.
  • Upstream: seed.

push rebuilds the commits that changed the splice's folder. It looks for them under the folder's current path only, so it doesn't see the commits made under the old one, and the move commit appears to create the whole folder.

Workaround: push before moving a splice, as shown here.

Output​

setup.bash builds this state:

$ build_scenario scenario_moved_with_unpushed_commits

Before the move, the local commit is waiting to be pushed:

$ git splice log
=== vendor/a (main)
< e859a6b local change (Test <test@example.com>)

Someone else reorganizes the folders:

$ git mv vendor/a libs/a && git -c user.name=Mover -c user.email=mover@example.com commit -q -m "reorganize folders"

The splice's fetched refs stay under the old path (#21), so fetch under the new one first:

$ git splice fetch libs/a
ok libs/a fetched

Now the move is the only commit to push. The local commit is gone from the list:

$ git splice log
=== libs/a (main)
< a9da2f2 reorganize folders (Mover <mover@example.com>)

The push sends the right content, as one commit with the move's message and author:

$ git splice push libs/a
ok libs/a: pushed a9da2f2 to main
$ git -C "$UPSTREAM" log --format='%s (%an)' main
reorganize folders (Mover)
seed (Test)
$ git -C "$UPSTREAM" show --format= main
diff --git a/file.txt b/file.txt
index e31de1f..d939bfa 100644
--- a/file.txt
+++ b/file.txt
@@ -1 +1,2 @@
seed
+local change