git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "igor.mikushkin" <igor.mikushkin@gmail.com>
To: git@vger.kernel.org
Subject: Re: Why git silently replaces untracked files?
Date: Fri, 25 Mar 2011 10:53:48 -0700 (PDT)	[thread overview]
Message-ID: <1301075628970-6208585.post@n2.nabble.com> (raw)
In-Reply-To: <20110325165811.GB25851@sigill.intra.peff.net>


Jeff King wrote:
> 
> On Fri, Mar 25, 2011 at 07:52:34AM -0700, igor.mikushkin wrote:
> 
> &gt; Why git silently replaces untracked files?
> &gt; 
> &gt; # mkdir test.git
> &gt; # mkdir 1
> &gt; # mkdir 2
> &gt; # echo 1 &gt; 1/test
> &gt; # echo 2 &gt; 2/test
> &gt; # cd test.git
> &gt; # git init --bare
> &gt; # cd ..
> &gt; # git clone test.git
> &gt; # cp -r test/.git 1
> &gt; # cp -r test/.git 2
> &gt; # cd 1
> &gt; # git add test
> &gt; # git commit -am 1
> &gt; # git push origin master
> &gt; # cd ../2
> &gt; # git pull
> &gt; # cat test
> &gt; 1
> &gt; 
> &gt; In my opinion it is wrong behavior.
> &gt; I've just lost important file due to it.
> &gt; 
> &gt; Should not &quot;git pull&quot; fail here?
> 
> Ick, definitely it's wrong behavior. The culprit seems to be a special
> code path for the initial pull which doesn't merge at all, but calls
> read-tree --reset. It should probably be:
> 
> diff --git a/git-pull.sh b/git-pull.sh
> index a3159c3..fb9e2df 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -253,7 +253,7 @@ esac
>  if test -z &quot;$orig_head&quot;
>  then
>  	git update-ref -m &quot;initial pull&quot; HEAD $merge_head
> &quot;$curr_head&quot; &amp;&amp;
> -	git read-tree --reset -u HEAD || exit 1
> +	git read-tree -m -u HEAD || exit 1
>  	exit
>  fi
> 
> Though I don't know if there are any cases where the --reset would be
> beneficial over &quot;-m&quot;. I couldn't think of any.
> 

Thanks Jeff,
My opinion is that you are right and merging is best here
(Though just fail would be probably OK either).
Love one line fixes.

Igor

--
View this message in context: http://git.661346.n2.nabble.com/Why-git-silently-replaces-untracked-files-tp6207950p6208585.html
Sent from the git mailing list archive at Nabble.com.

  reply	other threads:[~2011-03-25 17:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-25 14:52 Why git silently replaces untracked files? igor.mikushkin
2011-03-25 16:58 ` Jeff King
2011-03-25 17:53   ` igor.mikushkin [this message]
2011-03-25 18:06     ` Jeff King
2011-03-25 18:08       ` [PATCH 1/4] t7607: mark known breakage in test 11 as fixed Jeff King
2011-03-25 18:09       ` [PATCH 2/4] t7607: clean up stray untracked file Jeff King
2011-03-25 18:10       ` [PATCH 3/4] merge: merge unborn index before setting ref Jeff King
2011-03-25 18:13       ` [PATCH 4/4] pull: do not clobber untracked files on initial pull 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=1301075628970-6208585.post@n2.nabble.com \
    --to=igor.mikushkin@gmail.com \
    --cc=git@vger.kernel.org \
    /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 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).