New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion is incorrect due to the default core.ignorecase #87

Closed
emilianbold opened this Issue Dec 30, 2016 · 7 comments

Comments

Projects
None yet
3 participants
@emilianbold
Contributor

emilianbold commented Dec 30, 2016

I have some changesets that just change the case of a file name (eg. from HTMLLexer.java to HtmlLexer.java).

hg-fast-export seems to produce an invalid git commit, because I am running conversion on macOS, where git init creates a repository with core.ignorecase=true.

I don't believe there is any way to fix this other than re-running the conversion (is it?).

If I run git config core.ignorecase false before executing hg-fast-export the conversion is correct.

How to reproduce the issue:

$ mkdir case-bug
$ cd case-bug/
$ mkdir m
$ cd m/
$ hg init .
$ echo 'a' > A
$ hg add A 
$ hg commit -m "Added A"
$ mv A a
$ ls
a
$ hg mv A a
$ hg st
A a
R A
$ hg commit -m 'Renaming A -> a'
$ hg st
$ hg log -p 
changeset:   1:b68723268fab
tag:         tip
user:        Emilian Bold <emilian.bold at gmail.com>
date:        Fri Dec 30 14:41:40 2016 +0200
summary:     Renaming A -> a

diff -r 5cffc220b750 -r b68723268fab A
--- a/A	Fri Dec 30 14:41:26 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-a
diff -r 5cffc220b750 -r b68723268fab a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/a	Fri Dec 30 14:41:40 2016 +0200
@@ -0,0 +1,1 @@
+a

changeset:   0:5cffc220b750
user:        Emilian Bold <emilian.bold at gmail.com>
date:        Fri Dec 30 14:41:26 2016 +0200
summary:     Added A

diff -r 000000000000 -r 5cffc220b750 A
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/A	Fri Dec 30 14:41:26 2016 +0200
@@ -0,0 +1,1 @@
+a

$ cd ..
$ mkdir g
$ cd g/
$ git init .
Initialized empty Git repository in /Users/apache/work/case-bug/g/.git/
$ ~/work/fast-export/hg-fast-export.sh -r ../m/
master: Exporting full revision 1/2 with 1/0/0 added/changed/removed files
master: Exporting simple delta revision 2/2 with 1/0/1 added/changed/removed files
Issued 2 commands
Unpacking objects: 100% (4/4), done.
git-fast-import statistics:
---------------------------------------------------------------------
Alloc\'d objects:       5000
Total objects:            4 (         2 duplicates                  )
      blobs  :            1 (         1 duplicates          0 deltas of          0 attempts)
      trees  :            1 (         1 duplicates          0 deltas of          1 attempts)
      commits:            2 (         0 duplicates          0 deltas of          0 attempts)
      tags   :            0 (         0 duplicates          0 deltas of          0 attempts)
Total branches:           1 (         1 loads     )
      marks:           1024 (         2 unique    )
      atoms:              1
Memory total:          2344 KiB
       pools:          2110 KiB
     objects:           234 KiB
---------------------------------------------------------------------
pack_report: getpagesize()            =       4096
pack_report: core.packedGitWindowSize = 1073741824
pack_report: core.packedGitLimit      = 8589934592
pack_report: pack_used_ctr            =          0
pack_report: pack_mmap_calls          =          0
pack_report: pack_open_windows        =          0 /          0
pack_report: pack_mapped              =          0 /          0
---------------------------------------------------------------------

$ cd ..
$ git clone g g-work
Cloning into 'g-work'...
done.
$ cd g-work/
$ ls
A
$ git log -p -r
commit 0641070dea5994d86fe59547130467cf0e50152e
Author: Emilian Bold <emilian.bold at gmail.com>
Date:   Fri Dec 30 14:41:40 2016 +0200

    Renaming A -> a

commit 895726cb47653df10167fc71892328fa124e2787
Author: Emilian Bold <emilian.bold at gmail.com>
Date:   Fri Dec 30 14:41:26 2016 +0200

    Added A

diff --git a/A b/A
new file mode 100644
index 0000000..7898192
--- /dev/null
+++ b/A
@@ -0,0 +1 @@
+a

With git config core.ignorecase false:

g2-work apache$ git log -p -r
commit 8774dea085bd099c38904d48dacc557147fcb201
Author: Emilian Bold <emilian.bold@gmail.com>
Date:   Fri Dec 30 14:41:40 2016 +0200

    Renaming A -> a

diff --git a/A b/a
similarity index 100%
rename from A
rename to a

commit 895726cb47653df10167fc71892328fa124e2787
Author: Emilian Bold <emilian.bold@gmail.com>
Date:   Fri Dec 30 14:41:26 2016 +0200

    Added A

diff --git a/A b/A
new file mode 100644
index 0000000..7898192
--- /dev/null
+++ b/A
@@ -0,0 +1 @@
+a
@frej

This comment has been minimized.

Show comment
Hide comment
@frej

frej Dec 30, 2016

Owner

Dealing with broken file systems is outside the scope of fast-export. If you want the conversion to be usable for people using a case sensitive FS, run git with core.ignorecase=false (as you have already discovered).

I'm not sure I'd say that the commit is invalid in the first case. A checked out commit will give you the same tree as if you checked out the corresponding hg commit using the same file system.

Owner

frej commented Dec 30, 2016

Dealing with broken file systems is outside the scope of fast-export. If you want the conversion to be usable for people using a case sensitive FS, run git with core.ignorecase=false (as you have already discovered).

I'm not sure I'd say that the commit is invalid in the first case. A checked out commit will give you the same tree as if you checked out the corresponding hg commit using the same file system.

@frej frej added the won't-fix label Dec 30, 2016

@emilianbold

This comment has been minimized.

Show comment
Hide comment
@emilianbold

emilianbold Dec 30, 2016

Contributor

Checking out with hg produces the correct filename. It's only the git repo that's broken.

I was expecting that hg-fast-export just massages the patch file and imports it into git. It's a bit worrisome that it depends on unknown git flags whose defaults depend on the OS running git at the time. hg-fast-export should produce the same output all the time.

The least I suggest patching hg-fast-export to flat out refuse to run if core.ignorecase=true unless some flag is set (perhaps --force or some new flag) because it is almost certain to produce a bad conversion on any reasonably large repository where such case sensitive renames are bound to happen.

Also, I know Apple's filesystem is a joke for being case insensitive by default but a lot of people use macOS, this flag is non-obvious and hg-fast-export might produce git repositories that are silently corrupt (for example, by being correct in the current version but incorrect in older versions).

Contributor

emilianbold commented Dec 30, 2016

Checking out with hg produces the correct filename. It's only the git repo that's broken.

I was expecting that hg-fast-export just massages the patch file and imports it into git. It's a bit worrisome that it depends on unknown git flags whose defaults depend on the OS running git at the time. hg-fast-export should produce the same output all the time.

The least I suggest patching hg-fast-export to flat out refuse to run if core.ignorecase=true unless some flag is set (perhaps --force or some new flag) because it is almost certain to produce a bad conversion on any reasonably large repository where such case sensitive renames are bound to happen.

Also, I know Apple's filesystem is a joke for being case insensitive by default but a lot of people use macOS, this flag is non-obvious and hg-fast-export might produce git repositories that are silently corrupt (for example, by being correct in the current version but incorrect in older versions).

@frej

This comment has been minimized.

Show comment
Hide comment
@frej

frej Dec 30, 2016

Owner
Owner

frej commented Dec 30, 2016

@emilianbold

This comment has been minimized.

Show comment
Hide comment
@emilianbold

emilianbold Dec 30, 2016

Contributor

Send me a patch!

See pull request #88

Contributor

emilianbold commented Dec 30, 2016

Send me a patch!

See pull request #88

@frej

This comment has been minimized.

Show comment
Hide comment
@frej

frej Jan 1, 2017

Owner

Patch merged

Owner

frej commented Jan 1, 2017

Patch merged

@frej frej closed this Jan 1, 2017

@gk2go

This comment has been minimized.

Show comment
Hide comment
@gk2go

gk2go Aug 6, 2018

I've just got the same message, should i still get it since this was patched in 2017?

Error: The option core.ignoreCase is set to true in the git repository. This will produce empty changesets for renames that just change the case of the file name. Use --force to skip this check or change the option with git config core.ignoreCase false

gk2go commented Aug 6, 2018

I've just got the same message, should i still get it since this was patched in 2017?

Error: The option core.ignoreCase is set to true in the git repository. This will produce empty changesets for renames that just change the case of the file name. Use --force to skip this check or change the option with git config core.ignoreCase false

@emilianbold

This comment has been minimized.

Show comment
Hide comment
@emilianbold

emilianbold Aug 6, 2018

Contributor

Since the situation is ambiguous the tool would not run and throw that error. This is good.

You have to either:

  • use --force (I suspect this is needed quite rarely)
  • set git config core.ignoreCase false (I suspect this is most likely)

Only you know which makes sense for your repository.

Contributor

emilianbold commented Aug 6, 2018

Since the situation is ambiguous the tool would not run and throw that error. This is good.

You have to either:

  • use --force (I suspect this is needed quite rarely)
  • set git config core.ignoreCase false (I suspect this is most likely)

Only you know which makes sense for your repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment