git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] [git 2.16.1] yeeek ... my files are gone .. by git pull <otherRepositoryUrl>

From
Jeff King <peff@peff.net>
Date
Feb 23, 2018, 06:45 UTC
Message-ID
<20180223064549.GA19791@sigill.intra.peff.net>
In-Reply-To
<8A26AAB4-E2E5-4681-87D4-0D6727CA423A@childno.de>
On Fri, Feb 23, 2018 at 06:29:55AM +0100, "Marcel 'childNo͡.de' Trautwein" wrote:
> shows me a quite different behavior, so solely rebase not seems the full problem
> BUT
> `--rebase=preserve` will .. o’man , really, is this intended?

Yeah, the bug seems to be in --preserve-merges. Here's an easier reproduction:

  git init
  >one && git add one && git commit -m one
  git checkout --orphan other
  git mv one two && git commit -m two
  git rebase --preserve-merges master
at which point we've dropped commit "two" and its files entirely.

I don't know much about how preserve-merges works. It looks like in the loop around git-rebase--interactive.sh:931 that we mark commit "two" with preserve=t, and so we _don't_ add it to the list of commits to pick.

I think that stems from the fact that it has no parent marked to be rewritten.

So something like this helps:
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 81c5b42875..71e6cbb388 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -921,15 +921,20 @@ else
 
 		if test -z "$rebase_root"
 		then
 			preserve=t
+			p=
 			for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)
 			do
 				if test -f "$rewritten"/$p
 				then
 					preserve=f
 				fi
 			done
+			if test -z "$p"
+			then
+				preserve=f
+			fi
 		else
 			preserve=f
 		fi
 		if test f = "$preserve"

Because it at least adds "two" to the list of commits to pick. But
oddly, it picks it directly as a root commit again. Whereas a rebase
without --preserve-merges (and even "-i") picks it on top of commit
"one" (which is what I'd expect).

+cc Dscho, as the --preserve-merges guru.

-Peff
Previous: Marcel 'childNo͡.de' TrautweinNext: Johannes Schindelin
Message 4 of 8 in “[BUG] [git 2.16.1] yeeek ... my files are gone .. by git pull <otherRepositoryUrl>”
  1. Marcel 'childNo͡.de' TrautweinFeb 22, 2018
  2. Jonathan NiederFeb 22, 2018
  3. Marcel 'childNo͡.de' TrautweinFeb 23, 2018
  4. Jeff KingFeb 23, 2018
  5. Johannes SchindelinFeb 26, 2018
  6. Jeff KingFeb 28, 2018
  7. Johannes SchindelinMar 5, 2018
  8. Jeff KingMar 5, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.