Skip to content

show :my_file.txt missing a trailing newline #503

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

Closed
MaxLap opened this issue Dec 28, 2020 · 1 comment
Closed

show :my_file.txt missing a trailing newline #503

MaxLap opened this issue Dec 28, 2020 · 1 comment

Comments

@MaxLap
Copy link

MaxLap commented Dec 28, 2020

Subject of the issue

Using g.show(":my_file.txt") to see the file as it is returns a string missing the last newline.

Your environment

git: git version 2.28.0
ruby-git: 1.7.0
ruby: ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]

Steps to reproduce

require "git"

puts Git::VERSION

Dir.mktmpdir("git_auto_fixup_test") do |root|
  g = Git.init(root)
  g.commit("Initial commit", allow_empty: true)

  File.write("#{root}/my_file.txt", "hello\nworld\n")
  g.add("my_file.txt")

  puts "From gem: #{g.show(":my_file.txt").inspect}"
  puts "From git: #{`git -C #{root} show :my_file.txt`.inspect}"
end

Note that only 1 newline is removed. If I put more than one at the end, ruby-git will return one less.

Actual behaviour

1.7.0
From gem: "hello\nworld"
From git: "hello\nworld\n"

Expected behaviour

1.7.0
From gem: "hello\nworld\n"
From git: "hello\nworld\n"
@jcouball
Copy link
Member

This is fixed in git-1.8.1.

Actual Behavior

1.8.1
From gem: "hello\nworld\n"
From git: "hello\nworld\n"

jcouball added a commit that referenced this issue Jan 18, 2021
Refs #503

Signed-off-by: James Couball <jcouball@yahoo.com>
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

No branches or pull requests

2 participants