parent = repo.refs[repo.HEAD] c2 = repo.create_commit(t2, "second commit", parents=[parent]) repo.refs[repo.HEAD] = c2 ## let's create a subdirectory now t["subdir"] = {"foo.txt": "file in subdir"} ## this time we'll use the higher-level commit method c3 = repo.commit(t, "added subdir") ## retrieve subdir/foo.txt from HEAD assert repo.retrieve_commit()["subdir"]["foo.txt"] == "file in subdir" # now let's create a branch repo.create_branch("branch-test") repo.checkout_branch("branch-test") t = repo.retrieve_commit() t["subdir"]["foo.txt"] = "changed!" c4 = repo.commit(t, "changed file in subdirectory") ## this should print "changed!" assert repo.retrieve_commit()["subdir"]["foo.txt"] == "changed!"
## let's create a subdirectory now t["subdir"] = { "foo.txt": "file in subdir" } ## this time we'll use the higher-level commit method c3 = repo.commit(t, "added subdir") ## retrieve subdir/foo.txt from HEAD assert repo.retrieve_commit()["subdir"]["foo.txt"] == "file in subdir" # now let's create a branch repo.create_branch("branch-test") repo.checkout_branch("branch-test") t = repo.retrieve_commit() t["subdir"]["foo.txt"] = "changed!" c4 = repo.commit(t, "changed file in subdirectory") ## this should print "changed!"