~mdw
/
stgit
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
git.pretty_commit() re-implemented with "git show" (bug #10018)
[stgit]
/
stgit
/
git.py
diff --git
a/stgit/git.py
b/stgit/git.py
index
6744be0
..
27d2595
100644
(file)
--- a/
stgit/git.py
+++ b/
stgit/git.py
@@
-366,13
+366,20
@@
def create_branch(new_branch, tree_id = None):
if branch_exists(new_branch):
raise GitException, 'Branch "%s" already exists' % new_branch
if branch_exists(new_branch):
raise GitException, 'Branch "%s" already exists' % new_branch
+ current_head_file = get_head_file()
current_head = get_head()
set_head_file(new_branch)
__set_head(current_head)
# a checkout isn't needed if new branch points to the current head
if tree_id:
current_head = get_head()
set_head_file(new_branch)
__set_head(current_head)
# a checkout isn't needed if new branch points to the current head
if tree_id:
- switch(tree_id)
+ try:
+ switch(tree_id)
+ except GitException:
+ # Tree switching failed. Revert the head file
+ set_head_file(current_head_file)
+ delete_branch(new_branch)
+ raise
if os.path.isfile(os.path.join(basedir.get(), 'MERGE_HEAD')):
os.remove(os.path.join(basedir.get(), 'MERGE_HEAD'))
if os.path.isfile(os.path.join(basedir.get(), 'MERGE_HEAD')):
os.remove(os.path.join(basedir.get(), 'MERGE_HEAD'))
@@
-808,13
+815,10
@@
def barefiles(rev1, rev2):
return '\n'.join(result)
return '\n'.join(result)
-def pretty_commit(commit_id = 'HEAD',
diff_
flags = []):
+def pretty_commit(commit_id = 'HEAD', flags = []):
"""Return a given commit (log + diff)
"""
"""Return a given commit (log + diff)
"""
- return GRun('diff-tree',
- *(diff_flags
- + ['--cc', '--always', '--pretty', '-r', commit_id])
- ).raw_output()
+ return GRun('show', *(flags + [commit_id])).raw_output()
def checkout(files = None, tree_id = None, force = False):
"""Check out the given or all files
def checkout(files = None, tree_id = None, force = False):
"""Check out the given or all files