diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-11-24 22:05:05 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-11-24 22:05:05 +0100 |
commit | b81273e70c9c31ae02cb0a2d6e697d7a4e2b683a (patch) | |
tree | 6921def19b0a0570237232b73ed124528e90d41e | |
parent | 968ffb2c2e5c6066a2b01ad2a0833c2800880d46 (diff) | |
download | gitpython-b81273e70c9c31ae02cb0a2d6e697d7a4e2b683a.tar.gz |
Adjusted remaining usages of set_reference and set_commit to set a logmessage
-rw-r--r-- | index/base.py | 18 | ||||
-rw-r--r-- | objects/commit.py | 2 | ||||
-rw-r--r-- | objects/submodule/base.py | 2 | ||||
-rw-r--r-- | test/test_repo.py | 2 |
4 files changed, 18 insertions, 6 deletions
diff --git a/index/base.py b/index/base.py index a63dbb26..d813e6c1 100644 --- a/index/base.py +++ b/index/base.py @@ -933,7 +933,14 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): If one of files or directories do not exist in the index ( as opposed to the original git command who ignores them ). Raise GitCommandError if error lines could not be parsed - this truly is - an exceptional state""" + an exceptional state + + .. note:: The checkout is limited to checking out the files in the + index. Files which are not in the index anymore and exist in + the working tree will not be deleted. This behaviour is fundamentally + different to *head.checkout*, i.e. if you want git-checkout like behaviour, + use head.checkout instead of index.checkout. + """ args = ["--index"] if force: args.append("--force") @@ -1055,7 +1062,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): If False, the working tree will not be touched Please note that changes to the working copy will be discarded without warning ! - + :param head: If True, the head will be set to the given commit. This is False by default, but if True, this method behaves like HEAD.reset. @@ -1067,6 +1074,11 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): :param kwargs: Additional keyword arguments passed to git-reset + + .. note:: IndexFile.reset, as opposed to HEAD.reset, will not delete anyfiles + in order to maintain a consistent working tree. Instead, it will just + checkout the files according to their state in the index. + If you want git-reset like behaviour, use *HEAD.reset* instead. :return: self """ # what we actually want to do is to merge the tree into our existing @@ -1098,7 +1110,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # END handle working tree if head: - self.repo.head.commit = self.repo.commit(commit) + self.repo.head.set_commit(self.repo.commit(commit), logmsg="%s: Updating HEAD" % commit) # END handle head change return self diff --git a/objects/commit.py b/objects/commit.py index 883d6a6c..69a3adc4 100644 --- a/objects/commit.py +++ b/objects/commit.py @@ -356,7 +356,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): # Happens on first commit import git.refs master = git.refs.Head.create(repo, repo.head.ref, commit=new_commit, logmsg="commit (initial): %s" % message) - repo.head.reference = master + repo.head.set_reference(master, logmsg='commit: Switching to %s' % master) # END handle empty repositories # END advance head handling diff --git a/objects/submodule/base.py b/objects/submodule/base.py index 5d32d600..36b48d78 100644 --- a/objects/submodule/base.py +++ b/objects/submodule/base.py @@ -344,7 +344,7 @@ class Submodule(util.IndexObject, Iterable, Traversable): # END initial checkout + branch creation # make sure HEAD is not detached - mrepo.head.ref = local_branch + mrepo.head.set_reference(local_branch, logmsg="submodule: attaching head to %s" % local_branch) mrepo.head.ref.set_tracking_branch(remote_branch) except IndexError: print >> sys.stderr, "Warning: Failed to checkout tracking branch %s" % self.branch_path diff --git a/test/test_repo.py b/test/test_repo.py index 95b0750a..f517b9f1 100644 --- a/test/test_repo.py +++ b/test/test_repo.py @@ -568,7 +568,7 @@ class TestRepo(TestBase): assert rev_parse('@{1}') != head.commit # position doesn't exist - self.failUnlessRaises(BadObject, rev_parse, '@{10000}') + self.failUnlessRaises(IndexError, rev_parse, '@{10000}') # currently, nothing more is supported self.failUnlessRaises(NotImplementedError, rev_parse, "@{1 week ago}") |