All of lore.kernel.org
 help / color / mirror / Atom feed
From: "\"Marcel 'childNo͡.de' Trautwein\"" <c0d3+gitscm@childno.de>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [BUG] [git 2.16.1] yeeek ... my files are gone .. by git pull <otherRepositoryUrl>
Date: Fri, 23 Feb 2018 06:29:55 +0100	[thread overview]
Message-ID: <8A26AAB4-E2E5-4681-87D4-0D6727CA423A@childno.de> (raw)
In-Reply-To: <20180222232031.GE256918@aiede.svl.corp.google.com>

> Am 23.02.2018 um 00:20 schrieb Jonathan Nieder <jrnieder@gmail.com>:
> 
> Hi Marcel,
> 
> …
> Sorry, this is not the most helpful reply but:
> 
> Can you describe a reproduction recipe so that I can experience the
> same thing?
> 
> That is:
> 
> 1. steps to reproduce
> 2. expected result
> 3. actual result
> 4. the difference and why it was unexpected
> 

1. steps to reproduce
=====================
```
Last login: Fri Feb 23 00:33:11 on ttys001
~ PATH variable not enhanced, no applications found in ~/Applications/*-latest


-bash:/Users/marcel:$ mkdir /tmp/$$
change to new directory '/tmp/2608'? [Y/n] 


-bash:/tmp/2608:$ mkdir a.git
change to new directory 'a.git'? [Y/n] 


-bash:/tmp/2608/a.git:$ git init
Initialized empty Git repository in /private/tmp/2608/a.git/.git/


-bash:/tmp/2608/a.git:$ touch foo


-bash:/tmp/2608/a.git:$ git add foo


-bash:/tmp/2608/a.git:$ git commit -m "foo" foo
[master (root-commit) ed191c4] foo
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo


-bash:/tmp/2608/a.git:$ cd -
/tmp/2608


-bash:/tmp/2608:$ mkdir b.git
change to new directory 'b.git'? [Y/n] 


-bash:/tmp/2608/b.git:$ git init
Initialized empty Git repository in /private/tmp/2608/b.git/.git/


-bash:/tmp/2608/b.git:$ touch bar


-bash:/tmp/2608/b.git:$ git add bar


-bash:/tmp/2608/b.git:$ git commit -m "bar" bar
[master (root-commit) 80b0355] bar
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 bar


-bash:/tmp/2608/b.git:$ cd -
/tmp/2608


-bash:/tmp/2608:$ git clone a.git c
Cloning into 'c'...
done.


-bash:/tmp/2608:$ cd c


-bash:/tmp/2608/c:$ ll
total 0
drwxr-xr-x  12 marcel  wheel   384B 23 Feb 05:47 .git
-rw-r--r--   1 marcel  wheel     0B 23 Feb 05:47 foo


-bash:/tmp/2608/c:$ git pull ../b.git/
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../b
 * branch            HEAD       -> FETCH_HEAD
Successfully rebased and updated refs/heads/master.


-bash:/tmp/2608/c:$ ll
total 0
drwxr-xr-x  14 marcel  wheel   448B 23 Feb 05:47 .git
-rw-r--r--   1 marcel  wheel     0B 23 Feb 05:47 bar


-bash:/tmp/2608/c:$ git reflog
80b0355 (HEAD -> master) HEAD@{0}: pull ../b.git/: checkout 80b03552466bc526b1130ce5ca4a991ba31a0546: returning to refs/heads/master
80b0355 (HEAD -> master) HEAD@{1}: pull ../b.git/: checkout 80b03552466bc526b1130ce5ca4a991ba31a0546
ed191c4 (origin/master, origin/HEAD) HEAD@{2}: clone: from /tmp/2608/a.git


-bash:/tmp/2608/c:$ git remote -v
origin	/tmp/2608/a.git (fetch)
origin	/tmp/2608/a.git (push)


-bash:/tmp/2608/c:$  git log --all --graph --decorate --oneline --simplify-by-decoration
* 80b0355 (HEAD -> master) bar
* ed191c4 (origin/master, origin/HEAD) foo
```

2. expected result
==================
just an error in case the too trees have no common ancestors

```
-bash:/tmp/2608/c:$ git pull ../b.git/
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../b
 * branch            HEAD       -> FETCH_HEAD
fatal: refusing to merge unrelated histories
```

3. actual result
================
pulls out, removes all files from the first tree

4. the difference and why it was unexpected
===========================================
I can’t find words on it … it should not work but it did? somehow … with unexpected results to my local repository

it somehow seems to be an issue of my config, because resetting it, will not allow the pull as expected

```
-bash:/tmp/2608/c:$ GIT_CONFIG_NOSYSTEM=1 HOME=. git config -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=/tmp/2608/a.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master


-bash:/tmp/2608/c:$ GIT_CONFIG_NOSYSTEM=1 HOME=. git pull ../b.git/
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../b
 * branch            HEAD       -> FETCH_HEAD
fatal: refusing to merge unrelated histories


-bash:/tmp/2608/c:$ git pull ../b.git/
From ../b
 * branch            HEAD       -> FETCH_HEAD
Successfully rebased and updated refs/heads/master.
```

the logs tells me he rebases ...
```
-bash:/tmp/2608/c:$ git config -l | grep merge
diff.tool=p4merge
merge.tool=p4merge
merge.branchdesc=true
merge.log=true
branch.autosetupmerge=true
branch.master.merge=refs/heads/master


-bash:/tmp/2608/c:$ git config -l | grep pull
pull.rebase=preserve


-bash:/tmp/2608/c:$ git config -l | grep fetch
fetch.recursesubmodules=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
```


> I suspect that this information is in your message, somewhere, but it
> is (understandably) unfocussed and I am having trouble pulling it out.
> 

I’m sorry, I just wanted to write down first any helpful information without - being late - having time to go into further investigations myself … hopefully to get some answers that „this is ok, you’re just stupid and didn’t read the spec/doc“ or „ok, this seems strange to me too, can we go forward in details and analysis“ ;)

> [...]
>> trying to fix this up by doing another pull failed:
>> ```
>> -bash:$ git remote -v
>> origin	git@bitbucket.org:childnode/marcel.git (fetch)
>> origin	git@bitbucket.org:childnode/marcel.git (push)
>> 
>> -bash:$ git pull
>> fatal: refusing to merge unrelated histories
> 
> Ok, this part is something I might be able to help shed some light on.
> 
> Searching for 'unrelated' in "git help pull" finds:
> 
>       --allow-unrelated-histories
> 	   By default, git merge command refuses to merge histories that do not
> 	   share a common ancestor. This option can be used to override this
> 	   safety when merging histories of two projects that started their
> 	   lives independently. As that is a very rare occasion, no
> 	   configuration variable to enable this by default exists and will not
> 	   be added.
> 
> So that explains the "what" of that error message.
> 
> The "why" is a separate question.  Could you share output from
> 
>  git log --all --graph --decorate --oneline --simplify-by-decoration
> 
> and
> 
>  git status
> 

```
-bash:/tmp/2608/c:$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

nothing to commit, working tree clean


-bash:/tmp/2608/c:$ git branch -avv
* master                80b0355 [origin/master: ahead 1, behind 1] bar
  remotes/origin/HEAD   -> origin/master
  remotes/origin/master ed191c4 foo

```


> to help us understand your current state?
> 
> Also, suggestions for improvements to the 'refusing to merge' message
> would be very welcome.
> 
> Thanks and hope that helps,
> Jonathan

just to say: the latter „refused pull“ is what I expect the first time too!


SUSPECTED / PROVEN to found a guilty setting
=============================================
```
-bash:/tmp/2608/c:$ GIT_CONFIG_NOSYSTEM=1 HOME=. git -c user.name="me" -c user.email=me@example.com pull -r ../b.git/
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../b
 * branch            HEAD       -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: foo


-bash:/tmp/2608/c:$ ll
total 0
drwxr-xr-x  14 marcel  wheel   448B 23 Feb 06:21 .git
-rw-r--r--   1 marcel  wheel     0B 23 Feb 06:21 bar
-rw-r--r--   1 marcel  wheel     0B 23 Feb 06:21 foo

```
shows me a quite different behavior, so solely rebase not seems the full problem
BUT
`--rebase=preserve` will .. o’man , really, is this intended?

Yes, I see, rebase is a harmful operation and yes, you might now tell me a fool
to apply this per default

but why is this unrelated history check different from pull (merge) to rebase to rebase -p ?
Can’t find a word on it
https://git-scm.com/docs/git-rebase#git-rebase---preserve-merges


With regards,
~Marcel

  reply	other threads:[~2018-02-23  5:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-22 22:41 [BUG] [git 2.16.1] yeeek ... my files are gone .. by git pull <otherRepositoryUrl> "Marcel 'childNo͡.de' Trautwein"
2018-02-22 23:20 ` Jonathan Nieder
2018-02-23  5:29   ` "Marcel 'childNo͡.de' Trautwein" [this message]
2018-02-23  6:45     ` Jeff King
2018-02-26 23:33       ` Johannes Schindelin
2018-02-28 13:28         ` Jeff King
2018-03-05 14:49           ` Johannes Schindelin
2018-03-05 15:46             ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8A26AAB4-E2E5-4681-87D4-0D6727CA423A@childno.de \
    --to=c0d3+gitscm@childno.de \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.