Skip to content
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

Ignore 'No newline at end of file' log in patch #48

Closed
wants to merge 1 commit into from

Conversation

rwarren
Copy link

@rwarren rwarren commented Jul 4, 2023

This patch fixes this problem:

git_crecord.crpatch.PatchError: unknown patch content: b'\\ No newline at end of file\n'

@andrewshadura
Copy link
Owner

Interesting. Could you please also add a test? I haven’t run into this error, and the changes in bb52c3c were supposed to make it just work.

@andrewshadura
Copy link
Owner

I have also found another issue with EOL hunk parsing, #50. Not sure how to fix that at the moment. Your help with both issues would be appreciated 🙂

@rwarren
Copy link
Author

rwarren commented Jul 6, 2023

This PR can be rejected anyway, as it does not fix the problem (it just hides it temporarily). It successfully suppresses the exception on launch of git-record, but the commit fails when you try and make it (through git-record, anyway).

i.e. I found another problem which, when fixed, will hopefully yield a real solution.

One of the cases on this machine where I am seeing the exception I reported is a 723 line git diff where the \ No newline at end of file occurs in the middle of it (at line 251). Because of this, I tried replicating the problem as below:

$ git init .
Initialized empty Git repository in /home/russ/crecord_test/.git/
$ echo foo > foo
$ echo bar > bar
$ echo baz > baz
$ git add .
$ git commit -m "initial commit"
[main (root-commit) 8244a03] initial commit
 3 files changed, 3 insertions(+)
 create mode 100644 bar
 create mode 100644 baz
 create mode 100644 foo
$ # Now to modify all files, but change the "middle" one to have no newline
$ echo foo2 >> foo
$ printf "bar2" >> bar  # no newline
$ echo baz2 >> baz
$ git diff
diff --git a/bar b/bar
index 5716ca5..ee3bae5 100644
--- a/bar
+++ b/bar
@@ -1 +1,2 @@
 bar
+bar2
\ No newline at end of file
diff --git a/baz b/baz
index 7601807..5c18e2e 100644
--- a/baz
+++ b/baz
@@ -1 +1,2 @@
 baz
+baz2
diff --git a/foo b/foo
index 257cc56..b210800 100644
--- a/foo
+++ b/foo
@@ -1 +1,2 @@
 foo
+foo2

That generates a healthy diff with the "No newline" line as planned. However, git crecord at this time does not crash out like my initially shown exception. The UI launches without error.

However, you can see the UI is showing the \ No newline at end of file as a patch line:

image

NOTE: Since that did not show up in the "middle file", I tried various combos of no newline at the end of a file and can't replicate what consistently happens in my one repo state.

Anyway... there is still a problem, because when you try and commit that change (press c in the UI), it crashes out with patch does not apply like this:

$ git crecord
error: patch failed: bar:1
error: bar: patch does not apply
On branch main
nothing to commit, working tree clean
abort: commit failed: git exited with status 1

Hopefully whatever is causing this, when fixed, will also fix the other problem. There certainly seems to be an issue with handling that "No newline at end of file" issue. I don't understand your patch processing code enough right now to debug further.

@rwarren rwarren closed this Aug 2, 2023
@rwarren
Copy link
Author

rwarren commented Aug 2, 2023

Closed since it doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants