mkdir /tmp/scratch
cd /tmp/scratch
git init .
--*-- xx.rb:
SCRATCH = '/tmp/scratch'
repo = Repo.new(SCRATCH)
def add_multiple_commits_same_file_different_content(repo)
previous_commit = repo.commits.first && repo.commits.first.id
dir = "./"
(0...5).each do |count|
i1 = repo.index
i1.read_tree('master')
i1.add("#{dir}foo.txt", "hello foo, count is #{count}.\n")
dir += "sd#{count}/"
previous_commit = i1.commit("my commit - #{count}",
previous_commit,
Actor.new("j#{count}", "e@e#{count}.zz"),
previous_commit.nil? ? nil : repo.commits(previous_commit).first.tree)
end
end
add_multiple_commits_same_file_different_content(repo)
---* ---
git status:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: ./foo.txt
# deleted: ./sd0/foo.txt
# deleted: ./sd0/sd1/foo.txt
# deleted: ./sd0/sd1/sd2/foo.txt
# deleted: ./sd0/sd1/sd2/sd3/foo.txt
# deleted: ./sd0/sd1/sd2/sd3/sd4/foo.txt
---*----
If I try to check out the files they get deleted. Any ideas on hwta I am doing wrong.
Thanks John