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

Re: Not understanding with git wants to copy one file to another

From
Stefan Beller <sbeller@google.com>
Date
Aug 10, 2017, 17:36 UTC
Message-ID
<CAGZ79kbgb2P7KT_b9xuMj1pN1+jsPfH7YSJNDyDB5dY3cwXCQg@mail.gmail.com>
In-Reply-To
<87mv7773tp.fsf@local.lan>
On Thu, Aug 10, 2017 at 10:03 AM, Harry Putnam <reader@newsguy.com> wrote:
Show 26 quoted lines
> I ran into a line in git commit ouput I had not see before
>
>   #copied:     d0/etc/hosts -> misc/old-readerHOSTvcs-files/etc/hosts
>
> So googling I learned that this might happen if git thinks the two
> files are the same.
>
> I was pretty sure they were not the same so checked them>
>
>  <inside git repo>
>
> diff d0/etc/host misc/old-readerHOSTvcs-files/etc/hosts
>
> The output is a bit long but shows them being quite different.
>
> Some 2 dozen or so lines that dramatically differ.
>
> Here are two that are at least kind of similar but would never be seen
> as the same:
>
> < 192.168.1.43      m2.local.lan       m2       # 00-90-F5-A1-F9-E5
>> 192.168.1.43    m2.local.lan        m2         # win 7
>
> Not to mention they are quite different lines as well.
>
> So what is going on and what should I be looking at?

The diff machinery has a threshold for when it assumes a copy/move of a file. (e.g. "A file is assumed copied when at least 55% of lines are equal")

https://git-scm.com/docs/git-diff
See -C and -M option.

git-status seems to use this machinery as well, but does not expose the options?

Previous: Harry PutnamNext: Harry Putnam
Message 2 of 7 in “Not understanding with git wants to copy one file to another”
  1. Harry PutnamAug 10, 2017
  2. Stefan BellerAug 10, 2017
  3. Harry PutnamAug 10, 2017
  4. Stefan BellerAug 10, 2017
  5. Harry PutnamAug 11, 2017
  6. Stefan BellerAug 14, 2017
  7. Junio C HamanoAug 14, 2017

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.