git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elijah Newren <newren@gmail.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Lars Schneider <larsxschneider@gmail.com>,
	Jeff King <peff@peff.net>, Git Mailing List <git@vger.kernel.org>
Subject: Re: [BUG] Symbolic links break "git fast-export"?
Date: Mon, 1 Jul 2019 11:45:52 -0600	[thread overview]
Message-ID: <CABPp-BE0wbgn1OaEH-6TgBaEDrab9C-ZiQLbT9sS8PTf8E=CNQ@mail.gmail.com> (raw)
In-Reply-To: <5b00da7c-6836-0e61-8262-a9035126b658@kdbg.org>

On Sun, Jun 30, 2019 at 12:28 PM Johannes Sixt <j6t@kdbg.org> wrote:
>
> Am 30.06.19 um 15:05 schrieb Lars Schneider:
> >> On Jun 24, 2019, at 11:58 AM, Jeff King <peff@peff.net> wrote:
> >> You'd have to split the renames into separate delete/adds, since they
> >> can have a circular dependency. E.g. renaming "foo" to "bar" and "bar"
> >> to "foo", you must remove "foo" and "bar" both, and then add them back
> >> in.
> >
> > @peff: Can you give me a hint how one would perform this circular
> > dependency in a single commit? I try to write a test case for this.
>
> git mv Makefile foo
> git mv COPYING Makefile
> git mv foo COPYING
> git diff -B HEAD
>
> -- Hannes

Interestingly, fast-export has special code to handle cases like this;
possibly due to the understanding of how all
filemodify/filedelete/filerename commands take effect immediately (see
below for more on that).  If I make the above changes in git.git and
commit them, then:

$ git diff --name-status -B HEAD~1 HEAD
R100    Makefile        COPYING
R100    COPYING Makefile

BUT:

$ git fast-export -B -M --no-data HEAD~2..HEAD | tail -n 10
commit refs/heads/master
mark :7
author Elijah Newren <newren@gmail.com> 1562000065 -0600
committer Elijah Newren <newren@gmail.com> 1562000065 -0600
data 8
Testing
from :6
R COPYING Makefile
M 100644 8a7e2353520ddd7e0c8074d2b32d0441d97c1597 COPYING

I.e. fast-export breaks the rename and translates it into a modify
instead.  This comes from here:

        case DIFF_STATUS_COPIED:
        case DIFF_STATUS_RENAMED:
                /*
                 * If a change in the file corresponding to ospec->path
                 * has been observed, we cannot trust its contents
                 * because the diff is calculated based on the prior
                 * contents, not the current contents.  So, declare a
                 * copy or rename only if there was no change observed.
                 */
                if (!string_list_has_string(changed, ospec->path)) {
                        <snipped code for handling rename/copy>
                }
                /* fallthrough */
        case DIFF_STATUS_TYPE_CHANGED:
        case DIFF_STATUS_MODIFIED:
        case DIFF_STATUS_ADDED:

There is a question of whether fast-import should try to handle
different exporters that aren't as careful; e.g. if one gets a stream
like:

commit refs/heads/master
mark :4
author Me My <self@and.eye> 110000000 -0700
committer Me My <self@and.eye> 110000000 -0700
data 11
correction
R letters numbers
R numbers letters

Should git-fast-import attempt to divine the user's intent to swap
these two files (though it's not clear if that is the intent; see
below), or would that violate the documented behavior:

           A filerename command takes effect immediately. Once the source
           location has been renamed to the destination any future commands
           applied to the source location will create new files there and not
           impact the destination of the rename.

(I'm pretty sure Shawn would have said the latter; see e.g.
https://public-inbox.org/git/20100706193455.GA19476@spearce.org/ and
the follow-ups.)  I think the view of "immediately taking effect"
implies that this is a rename of 'letters' to 'numbers' which deletes
'numbers', and that the subsequent entry just renames the file back,
making it an expensive almost no-op; almost because it has the
side-effect of deleting the original 'numbers' file.  This is
certainly what fast-import does right now.

Elijah

  reply	other threads:[~2019-07-01 17:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24 11:03 [BUG] Symbolic links break "git fast-export"? Lars Schneider
2019-06-24 12:33 ` Elijah Newren
2019-06-24 18:58   ` Jeff King
2019-06-30 13:05     ` Lars Schneider
2019-06-30 18:28       ` Johannes Sixt
2019-07-01 17:45         ` Elijah Newren [this message]
2019-06-30 14:01   ` Lars Schneider
2019-07-01 18:02     ` Elijah Newren
2019-06-24 12:55 ` Elijah Newren

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='CABPp-BE0wbgn1OaEH-6TgBaEDrab9C-ZiQLbT9sS8PTf8E=CNQ@mail.gmail.com' \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=larsxschneider@gmail.com \
    --cc=peff@peff.net \
    /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).