Skip to content

Commit b81273e

Browse files
committed
Adjusted remaining usages of set_reference and set_commit to set a logmessage
1 parent 968ffb2 commit b81273e

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

index/base.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,14 @@ def checkout(self, paths=None, force=False, fprogress=lambda *args: None, **kwar
933933
If one of files or directories do not exist in the index
934934
( as opposed to the original git command who ignores them ).
935935
Raise GitCommandError if error lines could not be parsed - this truly is
936-
an exceptional state"""
936+
an exceptional state
937+
938+
.. note:: The checkout is limited to checking out the files in the
939+
index. Files which are not in the index anymore and exist in
940+
the working tree will not be deleted. This behaviour is fundamentally
941+
different to *head.checkout*, i.e. if you want git-checkout like behaviour,
942+
use head.checkout instead of index.checkout.
943+
"""
937944
args = ["--index"]
938945
if force:
939946
args.append("--force")
@@ -1055,7 +1062,7 @@ def reset(self, commit='HEAD', working_tree=False, paths=None, head=False, **kwa
10551062
If False, the working tree will not be touched
10561063
Please note that changes to the working copy will be discarded without
10571064
warning !
1058-
1065+
10591066
:param head:
10601067
If True, the head will be set to the given commit. This is False by default,
10611068
but if True, this method behaves like HEAD.reset.
@@ -1067,6 +1074,11 @@ def reset(self, commit='HEAD', working_tree=False, paths=None, head=False, **kwa
10671074
10681075
:param kwargs:
10691076
Additional keyword arguments passed to git-reset
1077+
1078+
.. note:: IndexFile.reset, as opposed to HEAD.reset, will not delete anyfiles
1079+
in order to maintain a consistent working tree. Instead, it will just
1080+
checkout the files according to their state in the index.
1081+
If you want git-reset like behaviour, use *HEAD.reset* instead.
10701082
10711083
:return: self """
10721084
# what we actually want to do is to merge the tree into our existing
@@ -1098,7 +1110,7 @@ def reset(self, commit='HEAD', working_tree=False, paths=None, head=False, **kwa
10981110
# END handle working tree
10991111

11001112
if head:
1101-
self.repo.head.commit = self.repo.commit(commit)
1113+
self.repo.head.set_commit(self.repo.commit(commit), logmsg="%s: Updating HEAD" % commit)
11021114
# END handle head change
11031115

11041116
return self

objects/commit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False):
356356
# Happens on first commit
357357
import git.refs
358358
master = git.refs.Head.create(repo, repo.head.ref, commit=new_commit, logmsg="commit (initial): %s" % message)
359-
repo.head.reference = master
359+
repo.head.set_reference(master, logmsg='commit: Switching to %s' % master)
360360
# END handle empty repositories
361361
# END advance head handling
362362

objects/submodule/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def update(self, recursive=False, init=True, to_latest_revision=False):
344344
# END initial checkout + branch creation
345345

346346
# make sure HEAD is not detached
347-
mrepo.head.ref = local_branch
347+
mrepo.head.set_reference(local_branch, logmsg="submodule: attaching head to %s" % local_branch)
348348
mrepo.head.ref.set_tracking_branch(remote_branch)
349349
except IndexError:
350350
print >> sys.stderr, "Warning: Failed to checkout tracking branch %s" % self.branch_path

test/test_repo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ def test_rev_parse(self):
568568
assert rev_parse('@{1}') != head.commit
569569

570570
# position doesn't exist
571-
self.failUnlessRaises(BadObject, rev_parse, '@{10000}')
571+
self.failUnlessRaises(IndexError, rev_parse, '@{10000}')
572572

573573
# currently, nothing more is supported
574574
self.failUnlessRaises(NotImplementedError, rev_parse, "@{1 week ago}")

0 commit comments

Comments
 (0)