* Disappearing change on pull rebase @ 2011-11-10 13:15 Pitucha, Stanislaw Izaak 2011-11-10 14:23 ` Kirill Likhodedov 0 siblings, 1 reply; 8+ messages in thread From: Pitucha, Stanislaw Izaak @ 2011-11-10 13:15 UTC (permalink / raw) To: git@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 1038 bytes --] Hi all, I've got an issue with some operations. It seems like git eats one of my commits (it's still in reflog, but in normal tree, it's unavailable). What I did is: checkout -b feature/.... (edit files and commit) checkout master merge --no-ff --no-commit feature/... (edit some files, change versions, changelog) commit Now I've got the change committed in the branch and some more changes on the merge commit. So before pushing to the main repo, I'd like to check if any other changes are there: pull --rebase Now my merge commit disappears completely along with the changes without any warning. I get the branch commits duplicated on top of master and the branch stays as it was. That looks like a data loss bug to me since I can only recover a committed change from reflog and there are no warnings before that change goes away (using 1.7.4.1). Actually no changes were done in upstream in the meantime, so the rebase was not even needed. Regards, Stanisław Pitucha Cloud Services Hewlett Packard [-- Attachment #2: smime.p7s --] [-- Type: application/x-pkcs7-signature, Size: 6216 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Disappearing change on pull rebase 2011-11-10 13:15 Disappearing change on pull rebase Pitucha, Stanislaw Izaak @ 2011-11-10 14:23 ` Kirill Likhodedov 2011-11-10 13:35 ` Pitucha, Stanislaw Izaak 0 siblings, 1 reply; 8+ messages in thread From: Kirill Likhodedov @ 2011-11-10 14:23 UTC (permalink / raw) To: Pitucha, Stanislaw Izaak; +Cc: git@vger.kernel.org 10.11.2011, в 16:15, Pitucha, Stanislaw Izaak: > Hi all, > I've got an issue with some operations. It seems like git eats one of my commits (it's still in reflog, but in normal tree, it's unavailable). > > What I did is: > > checkout -b feature/.... > (edit files and commit) > checkout master > merge --no-ff --no-commit feature/... > (edit some files, change versions, changelog) > commit > > Now I've got the change committed in the branch and some more changes on the merge commit. > So before pushing to the main repo, I'd like to check if any other changes are there: > > pull --rebase > > Now my merge commit disappears completely along with the changes without any warning. I get the branch commits duplicated on top of master and the branch stays as it was. > That looks like a data loss bug to me since I can only recover a committed change from reflog and there are no warnings before that change goes away (using 1.7.4.1). Actually no changes were done in upstream in the meantime, so the rebase was not even needed. > That is definitely not a bug. "git pull --rebase" is (almost?) equal to "git fetch ; git rebase origin/master" When you perform a rebase, at first your HEAD is rolled back to the commit before your changes, then it is fast-forwared to the remote HEAD (in your case, no fast-forward was made, because there were no remote changes); then your commits are applied one by one. Of couse, when your commits are applied, they are applied like patches. That mean, that they are different from the original commits (at least, by the commit time). That causes the duplication. And the merge commit "dissapeared", because it contained no changes, so the patch was empty, and there was nothing to reapply. If the merge commit contained some changes, and it really was not applied during rebase, it is a bug, but more details will be needed, I think. If you want to preserve your branch history, you should do "pull" without "rebase". Kirill. ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Disappearing change on pull rebase 2011-11-10 14:23 ` Kirill Likhodedov @ 2011-11-10 13:35 ` Pitucha, Stanislaw Izaak 2011-11-11 6:56 ` Johannes Sixt 0 siblings, 1 reply; 8+ messages in thread From: Pitucha, Stanislaw Izaak @ 2011-11-10 13:35 UTC (permalink / raw) To: git@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 2286 bytes --] As mentioned in the original mail - the merge commit did have changes. Here's the log of reproducing it. The line containing "2" in changelog is gone from master after pull --rebase. $ git init fake_upstream Initialized empty Git repository in /tmp/fake_upstream/.git/ $ cd fake_upstream/ fake_upstream$ echo some_content > test fake_upstream$ echo 1 > changelog fake_upstream$ git add test changelog fake_upstream$ git commit -m 'first commit' [master (root-commit) b1b683d] first commit 2 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 changelog create mode 100644 test fake_upstream$ cd .. $ git clone /tmp/fake_upstream/ disappearing_commit Cloning into disappearing_commit... done. $ cd disappearing_commit/ disappearing_commit$ git checkout -b some-branch Switched to a new branch 'some-branch' disappearing_commit$ echo blah >> test disappearing_commit$ git commit test -m 'branch modification' [some-branch 528f166] branch modification 1 files changed, 1 insertions(+), 0 deletions(-) disappearing_commit$ git checkout master Switched to branch 'master' disappearing_commit$ git merge --no-ff --no-commit some-branch Automatic merge went well; stopped before committing as requested disappearing_commit$ echo 2 >> changelog disappearing_commit$ git add changelog disappearing_commit$ git commit [master e41e4c9] Merge branch 'some-branch' disappearing_commit$ git show commit e41e4c963a72528e3b2b5945ca419e19cdba1e4b Merge: b1b683d 528f166 Author: Stanislaw Pitucha <stanislaw.pitucha@hp.com> Date: Thu Nov 10 13:30:04 2011 +0000 Merge branch 'some-branch' diff --cc changelog index d00491f,d00491f..1191247 --- a/changelog +++ b/changelog @@@ -1,1 -1,1 +1,2 @@@ 1 ++2 disappearing_commit$ git pull --rebase First, rewinding head to replay your work on top of it... Applying: branch modification disappearing_commit$ git show commit ef8f5e40db9fe7efbd4e493ff68b12327acde283 Author: Stanislaw Pitucha <stanislaw.pitucha@hp.com> Date: Thu Nov 10 13:29:33 2011 +0000 branch modification diff --git a/test b/test index 6e099dc..2f3f685 100644 --- a/test +++ b/test @@ -1 +1,2 @@ some_content +blah Regards, Stanisław Pitucha Cloud Services Hewlett Packard [-- Attachment #2: smime.p7s --] [-- Type: application/x-pkcs7-signature, Size: 6216 bytes --] ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: Disappearing change on pull rebase 2011-11-10 13:35 ` Pitucha, Stanislaw Izaak @ 2011-11-11 6:56 ` Johannes Sixt 2011-11-11 9:50 ` Philippe Vaucher 2011-11-11 16:31 ` Junio C Hamano 0 siblings, 2 replies; 8+ messages in thread From: Johannes Sixt @ 2011-11-11 6:56 UTC (permalink / raw) To: Pitucha, Stanislaw Izaak; +Cc: git@vger.kernel.org Am 11/10/2011 14:35, schrieb Pitucha, Stanislaw Izaak: > As mentioned in the original mail - the merge commit did have changes. > Here's the log of reproducing it. The line containing "2" in changelog > is gone from master after pull --rebase. > ... > disappearing_commit$ git merge --no-ff --no-commit some-branch > Automatic merge went well; stopped before committing as requested > disappearing_commit$ echo 2 >> changelog > disappearing_commit$ git add changelog > disappearing_commit$ git commit > [master e41e4c9] Merge branch 'some-branch' This is by design. Rebase does not rebase merge commits because it is assumed that merge commits only do what their name implies - to merge branches of a forked history. As such, they do not introduce their own changes. Follow this rule, i.e., make your change in a separate non-merge commit, and you are fine. -- Hannes ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Disappearing change on pull rebase 2011-11-11 6:56 ` Johannes Sixt @ 2011-11-11 9:50 ` Philippe Vaucher 2011-11-11 10:04 ` Johannes Sixt 2011-11-11 16:31 ` Junio C Hamano 1 sibling, 1 reply; 8+ messages in thread From: Philippe Vaucher @ 2011-11-11 9:50 UTC (permalink / raw) To: Johannes Sixt; +Cc: Pitucha, Stanislaw Izaak, git@vger.kernel.org > This is by design. Rebase does not rebase merge commits because it is > assumed that merge commits only do what their name implies - to merge > branches of a forked history. As such, they do not introduce their own > changes. Follow this rule, i.e., make your change in a separate non-merge > commit, and you are fine. Doesn't this create a problem if you pull, resolve a conflit but do NOT push, then pull --rebase some more commits later on? As I understand it, the conflict resolution commit will be a merge commit and will be thrown away by the git pull --rebase. Philippe ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Disappearing change on pull rebase 2011-11-11 9:50 ` Philippe Vaucher @ 2011-11-11 10:04 ` Johannes Sixt 2011-11-11 10:08 ` Philippe Vaucher 0 siblings, 1 reply; 8+ messages in thread From: Johannes Sixt @ 2011-11-11 10:04 UTC (permalink / raw) To: Philippe Vaucher; +Cc: Pitucha, Stanislaw Izaak, git@vger.kernel.org Am 11/11/2011 10:50, schrieb Philippe Vaucher: >> This is by design. Rebase does not rebase merge commits because it is >> assumed that merge commits only do what their name implies - to merge >> branches of a forked history. As such, they do not introduce their own >> changes. Follow this rule, i.e., make your change in a separate non-merge >> commit, and you are fine. > > Doesn't this create a problem if you pull, resolve a conflit but do NOT > push, then pull --rebase some more commits later on? As I understand > it, the conflict resolution commit will be a merge commit and will be > thrown away by the git pull --rebase. You are correct, but it is not a problem: During the rebase, the same conflicts will arise as during the merge, and you will be forced to resolve them before you can complete the rebase. Therefore, nothing will be lost. -- Hannes ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Disappearing change on pull rebase 2011-11-11 10:04 ` Johannes Sixt @ 2011-11-11 10:08 ` Philippe Vaucher 0 siblings, 0 replies; 8+ messages in thread From: Philippe Vaucher @ 2011-11-11 10:08 UTC (permalink / raw) To: Johannes Sixt; +Cc: Pitucha, Stanislaw Izaak, git@vger.kernel.org >> Doesn't this create a problem if you pull, resolve a conflit but do NOT >> push, then pull --rebase some more commits later on? As I understand >> it, the conflict resolution commit will be a merge commit and will be >> thrown away by the git pull --rebase. > > You are correct, but it is not a problem: During the rebase, the same > conflicts will arise as during the merge, and you will be forced to > resolve them before you can complete the rebase. Therefore, nothing will > be lost. Doing the same conflict resolution twice is kinda irritating... but ok, fair enough. I guess when you resolve a conflict you're supposed to push to avoid this :) Philippe ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Disappearing change on pull rebase 2011-11-11 6:56 ` Johannes Sixt 2011-11-11 9:50 ` Philippe Vaucher @ 2011-11-11 16:31 ` Junio C Hamano 1 sibling, 0 replies; 8+ messages in thread From: Junio C Hamano @ 2011-11-11 16:31 UTC (permalink / raw) To: Johannes Sixt; +Cc: Pitucha, Stanislaw Izaak, git@vger.kernel.org Johannes Sixt <j.sixt@viscovery.net> writes: > Am 11/10/2011 14:35, schrieb Pitucha, Stanislaw Izaak: >> As mentioned in the original mail - the merge commit did have changes. >> Here's the log of reproducing it. The line containing "2" in changelog >> is gone from master after pull --rebase. >> ... >> disappearing_commit$ git merge --no-ff --no-commit some-branch >> Automatic merge went well; stopped before committing as requested >> disappearing_commit$ echo 2 >> changelog >> disappearing_commit$ git add changelog >> disappearing_commit$ git commit >> [master e41e4c9] Merge branch 'some-branch' > > This is by design. Rebase does not rebase merge commits because it is > assumed that merge commits only do what their name implies - to merge > branches of a forked history. As such, they do not introduce their own > changes. Follow this rule, i.e., make your change in a separate non-merge > commit, and you are fine. While that may be technically correct, I wonder if we can be a bit more helpful to the users in such a case (upfront I admit that I have a strong suspicion that this is a hard problem in general). One typical use of "rebase" is to linearize a history that has unfortunate merges that did not have to be there, so refusing "git rebase A..B" when there is a merge in "git rev-list --merges A..B" is not a solution. But would it help if we warned about the merges when we find that there is something _interesting_ going on in them, e.g. an evil merge that adds material that did not exist in any of the parents [*1*]? The warning message may diagnose "you asked me to linearize the history by picking commits on the non-merge segments and replaying them, but there may be changes made in this merge commit, and it does this interesting thing: $(git show -c $that_merge_commit)" and may further suggest "if you do not want to linearize but just transplant the history, perhaps you want to run the command with the '-m' option?". [Footnote] *1* This is a hard problem and not just the matter of looking at "show -c" output. A "-s ours" merge would appear empty in "show -c" but it _is_ an interesting event that makes the result of linearizing non-merge segments vastly different from the original. Also material that did not exist in any of the parents is not necessarily evil (e.g. the side branch may have added one parameter to a function and updated its call sites, while our branch may have added a different parameter to the same function. The update to the call sites in the merge result should pass two more parameters from the common ancestor, and different from either of the parents). ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-11-11 16:31 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-11-10 13:15 Disappearing change on pull rebase Pitucha, Stanislaw Izaak 2011-11-10 14:23 ` Kirill Likhodedov 2011-11-10 13:35 ` Pitucha, Stanislaw Izaak 2011-11-11 6:56 ` Johannes Sixt 2011-11-11 9:50 ` Philippe Vaucher 2011-11-11 10:04 ` Johannes Sixt 2011-11-11 10:08 ` Philippe Vaucher 2011-11-11 16:31 ` Junio C Hamano
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 NNTP newsgroup(s).