git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Thomas Klausner <tk@giga.or.at>, git@vger.kernel.org
Subject: Re: weird behaviour in git
Date: Thu, 26 Feb 2015 15:45:13 +0100	[thread overview]
Message-ID: <54EF3179.8030104@drmicha.warpmail.net> (raw)
In-Reply-To: <20150226141234.GP19896@danbala.tuwien.ac.at>

Thomas Klausner venit, vidit, dixit 26.02.2015 15:12:
> Hi!
> 
> I've played around with git and found that 'git mv' does not honor
> what I tell it to do:
> 
> wiz@yt:~> mkdir a
> wiz@yt:~> cd a
> wiz@yt:~/a> git init .
> Initialized empty Git repository in /home/wiz/a/.git/
> wiz@yt:~/a> touch a
> wiz@yt:~/a> git add a
> wiz@yt:~/a> git commit -m 'add a'
> [master (root-commit) 99d0ee7] add a
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 a
> wiz@yt:~/a> git mv a b
> wiz@yt:~/a> touch Makefile
> wiz@yt:~/a> git add Makefile
> wiz@yt:~/a> git commit
> 
> 
> # Please enter the commit message for your changes. Lines starting
> # with '#' will be ignored, and an empty message aborts the commit.
> # On branch master
> # Changes to be committed:
> #       renamed:    a -> Makefile
> #       new file:   b
> #
> 
> This is reproducible for me with "git version 2.3.0" on
> NetBSD-7.99.5/amd64.
> 
> I guess this happens because the checksums of the files are the same
> and 'Makefile' is earlier when sorting, but since I explicitly told
> "git mv" old and new name, I think that's a bug nevertheless.
>  Thomas
> 

git tracks content, not paths.

It does record the path at which the tracked content is, of course. But
it tracks the history of content, not that of paths.

What you see in the diff above is merely one way to interpret the
history of the content. Saying

renamed:  a -> b
new file: Makefile

leads to the same content at the same paths (with the proper new file
content).

By default, diff tries to interpret content history in terms of renames
and copies when possible, in order to help users. Sometimes this fails -
while still being correct, it confuses them ;)

Michael

  reply	other threads:[~2015-02-26 14:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26 14:12 weird behaviour in git Thomas Klausner
2015-02-26 14:45 ` Michael J Gruber [this message]
2015-02-26 14:58   ` Thomas Klausner
2015-02-26 15:22     ` Michael J Gruber
2015-02-26 15:54 ` David Kastrup

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=54EF3179.8030104@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=tk@giga.or.at \
    /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).