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

Re: Possible regression: overwriting untracked files in a fresh repo

From
Jeff King <peff@peff.net>
Date
Aug 24, 2009, 19:07 UTC
Message-ID
<20090824190710.GB25168@coredump.intra.peff.net>
In-Reply-To
<alpine.DEB.1.00.0908241829510.11375@intel-tinevez-2-302>
On Mon, Aug 24, 2009 at 06:31:21PM +0200, Johannes Schindelin wrote:
Show 8 quoted lines
> I _think_ that this used to complain about untracked files being 
> overwritten:
> 
> 	$ git init
> 	$ git remote add -f origin <url>
> 	$ git checkout -b blub origin/master
> 
> It does not do that here (any longer, IIAC).  Intended?

I agree that it probably _should_ complain, but I don't think it ever did. I tried a handful of released versions as far back as v1.4.4, and all of them overwrite local files without complaining. My test was:

-- >8 -- #!/bin/sh

rm -rf parent child
mkdir parent && (
  cd parent &&
  git init-db &&
  echo content >file &&
  git add file &&
  git commit -m add
) &&
mkdir child && (
  cd child &&
  git init-db &&
  git fetch ../parent master:origin &&
  echo precious >file &&
  ! git checkout -b foo origin
)
-- >8 --
However, if I then do this:
  (cd parent && echo content >another && git add . && git commit -m more)
  (cd child && git fetch ../parent && git checkout -b new FETCH_HEAD)

then it does complain. I'm guessing there is a different code path for the case that we have no index at all, and that it is not properly checking for overwrites.

But now I have a small child waking up so I can't look into it further. :)

-Peff
Previous: Johannes SchindelinNext: Junio C Hamano
Message 2 of 9 in “Possible regression: overwriting untracked files in a fresh repo”
  1. Johannes SchindelinAug 24, 2009
  2. Jeff KingAug 24, 2009
  3. Junio C HamanoAug 24, 2009
  4. Junio C HamanoAug 24, 2009
  5. Jeff KingAug 25, 2009
  6. Jeff KingAug 25, 2009
  7. Junio C HamanoAug 25, 2009
  8. Jeff KingAug 25, 2009
  9. Johannes SchindelinAug 25, 2009

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.