You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
import failure: "git diff header lacks filename information when removing 1 leading pathname component" #432
I'm trying to init a new lerna instance, and import some (very large) old repo's. And I am running into this error.
lerna import ../<some-large-repo>/
Lerna v2.0.0-beta.30
About to import 1947 commits into from ../<some-large-repo>/ into packages/<some-large-repo>
? Are you sure you want to import these commits onto the current branch? Yes
Errored while running ImportCommand.execute
Failed to apply commit a76cb3c23.
Error: Command failed: git am -3
error: git diff header lacks filename information when removing 1 leading pathname component (line 15046)
error: could not build fake ancestor
Rolling back to previous HEAD (commit 3ff03a0).
lerna import ../vortigern/
Lerna v2.0.0-beta.30
About to import 143 commits into from ../vortigern/ into packages/vortigern
? Are you sure you want to import these commits onto the current branch? Yes
Errored while running ImportCommand.execute
Failed to apply commit 518cae8.
Error: Command failed: git am -3
error: Failed to merge in the changes.
Rolling back to previous HEAD (commit 3ff03a0).
EDIT:
I tried with that repo on v29, because I saw there was some changes
lerna import ../vortigern/
Lerna v2.0.0-beta.29
About to import 143 commits into from ../vortigern/ into packages/vortigern
? Are you sure you want to import these commits onto the current branch? Yes
Errored while running ImportCommand.execute
Failed to apply commit 223310f.
Error: Command failed: git am -3
error: git apply: bad git-diff - inconsistent old filename on line 335
error: could not build fake ancestor
Rolling back to previous HEAD (commit a3c40c4).
Okay, great. Thanks for tracking down an open repro.
It looks from the error message like there may just be some filenames that we're failing to convert. The import command does some search-and-replace on patch files produced by git am.
It looks from the error message like there may just be some filenames that we're failing to convert. The import command does some search-and-replace on patch files produced by git am.
if I were to git diff a76cb3c23 and a76cb3c23^1 that would be the patch in question right? I'll see if I can find anything funny there
The best possible way to handle this IMO, is to get a list of all files changed in that commit, and look to see if any of them match the last file in the line and use that if so.
One gotcha to this approach is that you could have folder/file and folder folder/file data/file which could break the algorithm also. So it would be necessary to check longest file names first and work toward shortest.
If I have time tonight, I'll see if I can do a PR for this.
It does retain history, but maybe not as well as the original solution, as files are not listed as packages/<package>/folder/... but listed as folder/....
There is also a giant commit at the HEAD of the repo that adds every file,
blaming the file still seems to work fine everywhere I have looked.
But, on the other hand, we've had some issues with this import strategy for a long time. A simpler solution that always works might still be better even if it doesn't provide perfect history?
Do you have an idea about what the errors you're still seeing with your PR branch might be?
I updated the PR to use a better show file command, that allowed me to get through a couple hundred more commits but ran into a new one. But I think this issue will be closed by #434.
I'll see if I can figure out what is wrong with the next commits.
Sharing my experience since I ran into a brick wall when getting this issue.
The problem does indeed seem to be caused by files/folders in the history that have spaces in them (and has to do with this line only checking for non-whitespace \S characters). It seems like a pretty straightforward problem, but doesn't feel like it'd be a straightforward fix.
The way I got around this was by using the bfg repo cleaner to delete the offending files/folders (with spaces in them) from the history in my repo. Once I did that, lerna was able to import it successfully
actually covers most scenarios. The only ones it doesn't cover is filepaths containing specifically ' b/' (e.g. tests/scenario b/...). All other filespaths with spaces in them are covered, though.
It feels a little hacky, but I can submit a PR for it if you're interested
@chrisdothtml That looks pretty good to me. A PR with a regression test would be great!
(If we wanted to get suuuuuper finicky, we could actually set the --src-prefix and --dst-prefix to more ...robust? values, but I think that's an edge case we don't have to worry about right now)
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Activity
gigabo commentedon Dec 12, 2016
Yikes, that's a new one. Thanks for reporting @ericwooley.
Is
<some-large-repo>up on GitHub, by any chance? Looking for a way to repro this.ericwooley commentedon Dec 12, 2016
I wish or I would have provided it. Unfortunately its work for a client :(
I am trying to reproduce on something I can open source.
ericwooley commentedon Dec 12, 2016
@gigabo I found that I am having issues with this (which was the original fork)
https://github.com/ericwooley/vortigern
But a different error that simply says,
EDIT:
I tried with that repo on v29, because I saw there was some changes
ericwooley commentedon Dec 12, 2016
I also took a look at the proprietery commit in question from the original import
a76cb3c23And it is the addition of 30+ files, with several png's mixed in. Maybe the png files are part of the problem?
gigabo commentedon Dec 12, 2016
Okay, great. Thanks for tracking down an open repro.
It looks from the error message like there may just be some filenames that we're failing to convert. The import command does some search-and-replace on patch files produced by
git am.gigabo commentedon Dec 12, 2016
Like maybe something similar to #346, but for added files?
ericwooley commentedon Dec 12, 2016
if I were to git diff a76cb3c23 and a76cb3c23^1 that would be the patch in question right? I'll see if I can find anything funny there
ericwooley commentedon Dec 12, 2016
here is an excerpt that seems suspicious since there is a bunch of
/dev/null. stuff happeninggigabo commentedon Dec 12, 2016
Yeah, if you wanted to use the actual command that
importuses I think it would be:ericwooley commentedon Dec 12, 2016
@gigabo Do you have an email or something I can contact you through?
gigabo commentedon Dec 12, 2016
Easiest is probably to jump on slack.
gigabo commentedon Dec 12, 2016
Talked with @ericwooley a bit on slack, and it sounds like an added file with a space in the filename may be the culprit here.
In that case the diff looks like:
My guess is this is tripping up the replacement pattern here, which looks specifically for non-whitespace in the filename.
ericwooley commentedon Dec 12, 2016
@gigabo figured pointed out that it may have had to do with spaces in the file names, and he is correct.
an example output with a space is:
because it searches for the \S+ https://github.com/lerna/lerna/blob/master/src/commands/ImportCommand.js#L97
it breaks on whitespace.
EDIT
@gigabo YOU BEAT ME
ericwooley commentedon Dec 13, 2016
Looking through https://git-scm.com/docs/git-format-patch documentation, I don't see a way to output in a more parseable manner.
The best possible way to handle this IMO, is to get a list of all files changed in that commit, and look to see if any of them match the last file in the line and use that if so.
One gotcha to this approach is that you could have
folder/fileand folderfolder/file data/filewhich could break the algorithm also. So it would be necessary to check longest file names first and work toward shortest.If I have time tonight, I'll see if I can do a PR for this.
2 remaining items
use urlEncode to handle spaces in file names, closes lerna#432
Use urlEncode to handle spaces in file names, closes lerna#432
ericwooley commentedon Dec 13, 2016
@gigabo
I implemented my solution in PR #434
But am running into more problems, and I'm not sure what they are.
However, I did a little research, and isn't this exactly what git subtree is for? I was able to successfully bring in each repo from the answer here http://stackoverflow.com/questions/6426247/merge-git-repository-in-subdirectory
gigabo commentedon Dec 13, 2016
Whoa... that move all of the history in to the
packages/<my repo>path?How is the commit history attached? With a merge commit?
That sounds really promising!
ericwooley commentedon Dec 13, 2016
It does retain history, but maybe not as well as the original solution, as files are not listed as
packages/<package>/folder/...but listed asfolder/....There is also a giant commit at the HEAD of the repo that adds every file,
blaming the file still seems to work fine everywhere I have looked.
logging the file doesn't seem to work.
gigabo commentedon Dec 13, 2016
Oh, hmm... would be nice to preserve this. 😖
But, on the other hand, we've had some issues with this import strategy for a long time. A simpler solution that always works might still be better even if it doesn't provide perfect history?
Do you have an idea about what the errors you're still seeing with your PR branch might be?
ericwooley commentedon Dec 13, 2016
I updated the PR to use a better show file command, that allowed me to get through a couple hundred more commits but ran into a new one. But I think this issue will be closed by #434.
I'll see if I can figure out what is wrong with the next commits.
Patch parsing is aggravating.
gigabo commentedon Dec 13, 2016
Yeah, it is. 😞
Glad you were able to get past this error. Interested to learn what the next error is.
chrisdothtml commentedon Sep 4, 2018
Sharing my experience since I ran into a brick wall when getting this issue.
The problem does indeed seem to be caused by files/folders in the history that have spaces in them (and has to do with this line only checking for non-whitespace
\Scharacters). It seems like a pretty straightforward problem, but doesn't feel like it'd be a straightforward fix.The way I got around this was by using the bfg repo cleaner to delete the offending files/folders (with spaces in them) from the history in my repo. Once I did that, lerna was able to import it successfully
evocateur commentedon Sep 4, 2018
@chrisdothtml Ooh, yeah, that does look likely.
chrisdothtml commentedon Sep 5, 2018
Replacing line 161 with
actually covers most scenarios. The only ones it doesn't cover is filepaths containing specifically ' b/' (e.g.
tests/scenario b/...). All other filespaths with spaces in them are covered, though.It feels a little hacky, but I can submit a PR for it if you're interested
evocateur commentedon Sep 5, 2018
@chrisdothtml That looks pretty good to me. A PR with a regression test would be great!
(If we wanted to get suuuuuper finicky, we could actually set the
--src-prefixand--dst-prefixto more ...robust? values, but I think that's an edge case we don't have to worry about right now)lock commentedon Dec 27, 2018
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.