summaryrefslogtreecommitdiff
path: root/morphlib/gitindex_tests.py
Commit message (Collapse)AuthorAgeFilesLines
* Prevent git-replace refs affecting git operationsRichard Maw2014-08-211-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We assumed that the sha1 of the tree of the commit of the ref we care about was sufficient to cache, but `git replace` means that you need to know the state of other branches too, since anything in refs/replace can completely change what the tree you check-out is. This behaviour can be disabled globally by setting GIT_NO_REPLACE_OBJECTS, so we're going to do that. If we need to integrate a project that uses git-replace to change the contents of their git trees then we could support that by: if any(refs/replace/*): potentially_replacable_objects = [ `git rev-parse HEAD`, `git rev-parse HEAD^{commit}`, `git rev-parse HEAD^{tree}`] potentially_replacable_objects.extend( `git ls-tree -r HEAD | awk '{print $3}'`) # NOTE: doesn't handle submodules, and you'd need to expand this # set whenever you process a replacement for object in refs/replace/*: if basename(object) not in potentially_replacable_objects: continue cache_key['replacements'][basename(object)] = `git rev-parse $object` If we were to support this would need to traverse the tree anyway, doing replacements, so we may as well use libgit to do the checkout anyway, and list which replacements were used. However, since the expected use-case of `git replace` is as a better way to do history grafting, we're unlikely to need it, as it would only have any effect if it replaced the commit we were using with a different one. Rubber-stamped-by: Daniel Silverstone
* gitindex: Add GitIndex.write_tree()Richard Maw2013-11-221-0/+5
| | | | | This generates a tree object from the index. This can then be used to create a commit.
* gitindex: Add GitIndex.add_files_from_working_tree()Richard Maw2013-11-221-0/+12
| | | | | | | | | | This is like GitIndex.add_files_from_index_info, but uses the working tree and a list of paths. This is more convenient when the changes exist in the working tree. The comment describes its relationship with GitIndex.add_files_from_index_info, but it is faster, since it calls out to `git add` rather than calling out to `git hash-object` for every file.
* gitindex: Add GitIndex.add_files_from_index_info()Richard Maw2013-11-221-0/+10
| | | | | | This is used to add files directly to the index, without touching the working tree. This is used in the build without commit code for creating new morphologies pointing to different branches.
* gitindex: Add GitIndex.set_to_tree(treeish) methodRichard Maw2013-11-221-0/+9
| | | | | | | This is used to set the state of the index to that of a previously known commit. This is needed for the build without commit logic, so that commits generated are that of the last commit in the repository and anything uncommitted.
* GitDir: Add GitIndex classRichard Maw2013-11-221-0/+56
This represents the state of the index of a GitDirectory. Methods that use the index are now used via the GitIndex class, rather than using the default index, as previously used when the methods were in GitDirectory. GitIndex may be constructed with an alternative path, which can be used to manipulate a git checkout without altering a developer's view of the repository i.e. The working tree and default index. This is needed for `morph build` and `morph deploy` to handle the build without commit logic.