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

[BUG] Symbolic links break "git fast-export"?

From
Lars Schneider <larsxschneider@gmail.com>
Date
Jun 24, 2019, 11:03 UTC
Message-ID
<95EF0665-9882-4707-BB6A-94182C01BE91@gmail.com>
Hi folks,

Is my understanding correct, that `git fast-export | git fast-import` should not modify the repository? If yes, then we might have a bug in `git fast-export` if symbolic directory links are removed and converted to a real directory.

Consider this test case:
    # Create test repo
    git init .
    mkdir foo
    echo "foo" >foo/baz
    git add .
    git commit -m "add foo dir"
    ln -s foo bar
    git add .
    git commit -m "add bar dir as link"
    rm bar
    mkdir bar
    echo "bar" >bar/baz
    git add .
    git commit -m "remove link and make bar dir real"
    printf "BEFORE: "
    git rev-parse HEAD
    # Fast export, import ... that should not change anything!
    git fast-export --no-data --all --signed-tags=warn-strip \
        --tag-of-filtered-object=rewrite | git fast-import --force --quiet
    printf "AFTER: "

I would assume that the BEFORE/AFTER hashes match. Unfortunately, with Git 2.22.0 they do no. The problem is this export output I think:

    remove link and make bar dir real
    from :2
    M 100644 5716ca5987cbf97d6bb54920bea6adde242d87e6 bar/baz
    D bar

The new file in the `bar` directory is added to the repo first and afterwards the path `bar` is deleted. I think that deletes the entire directory `bar`?

If you confirm that this is a bug, then I will try to provide a fix.

Thanks, Lars

Next: Elijah Newren
Message 1 of 9 in “[BUG] Symbolic links break "git fast-export"?”
  1. Lars SchneiderJun 24, 2019
  2. Elijah NewrenJun 24, 2019
  3. Jeff KingJun 24, 2019
  4. Lars SchneiderJun 30, 2019
  5. Johannes SixtJun 30, 2019
  6. Elijah NewrenJul 1, 2019
  7. Lars SchneiderJun 30, 2019
  8. Elijah NewrenJul 1, 2019
  9. Elijah NewrenJun 24, 2019

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.