diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-11-24 22:53:24 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-11-24 22:53:24 +0100 |
commit | cf1d5bd4208514bab3e6ee523a70dff8176c8c80 (patch) | |
tree | d68f6529275838b9a962c4b76533e8445441af34 /objects/submodule/root.py | |
parent | 3175b5b21194bcc8f4448abe0a03a98d3a4a1360 (diff) | |
parent | 7da101ba9a09a22a85c314a8909fd23468ae66f0 (diff) | |
download | gitpython-cf1d5bd4208514bab3e6ee523a70dff8176c8c80.tar.gz |
Merge branch 'reflogintegration'
Diffstat (limited to 'objects/submodule/root.py')
-rw-r--r-- | objects/submodule/root.py | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/objects/submodule/root.py b/objects/submodule/root.py index d194cd5b..753c6df4 100644 --- a/objects/submodule/root.py +++ b/objects/submodule/root.py @@ -68,19 +68,15 @@ class RootModule(Submodule): ################## cur_commit = repo.head.commit if previous_commit is None: - symref = repo.head.orig_head() try: - previous_commit = symref.commit - except Exception: - pcommits = cur_commit.parents - if pcommits: - previous_commit = pcommits[0] - else: - # in this special case, we just diff against ourselve, which - # means exactly no change - previous_commit = cur_commit - # END handle initial commit - # END no ORIG_HEAD + previous_commit = repo.commit(repo.head.log_entry(-1).oldhexsha) + if previous_commit.binsha == previous_commit.NULL_BIN_SHA: + raise IndexError + #END handle initial commit + except IndexError: + # in new repositories, there is no previous commit + previous_commit = cur_commit + #END exception handling else: previous_commit = repo.commit(previous_commit) # obtain commit object # END handle previous commit @@ -207,12 +203,8 @@ class RootModule(Submodule): smm = sm.module() smmr = smm.remotes try: - tbr = git.Head.create(smm, sm.branch_name) - except git.GitCommandError, e: - if e.status != 128: - raise - #END handle something unexpected - + tbr = git.Head.create(smm, sm.branch_name, logmsg='branch: Created from HEAD') + except OSError: # ... or reuse the existing one tbr = git.Head(smm, sm.branch_path) #END assure tracking branch exists |