Allow tag objects to be passed on the command line
authorCatalin Marinas <catalin.marinas@gmail.com>
Fri, 17 Feb 2006 21:31:43 +0000 (21:31 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Fri, 17 Feb 2006 21:32:53 +0000 (21:32 +0000)
stgit.common.git_id() was modified to add '^0' to the revision so that a
tag can be used for different operations and the corresponding commit will
be returned. Commands like 'branch --create' were failing if a tag was
passed.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/branch.py
stgit/commands/common.py
stgit/git.py

index ef44349..cc74122 100644 (file)
@@ -124,7 +124,7 @@ def func(parser, options, args):
 
         tree_id = None
         if len(args) == 2:
-            tree_id = args[1]
+            tree_id = git_id(args[1])
 
         git.create_branch(args[0], tree_id)
         stack.Series(args[0]).init()
index 88f1433..f7301da 100644 (file)
@@ -81,7 +81,7 @@ def git_id(rev):
         return read_string(series.get_base_file())
 
     # anything else failed
-    return git.rev_parse(rev)
+    return git.rev_parse(rev + '^{commit}')
 
 def check_local_changes():
     if git.local_changes():
index 582e803..016bc3a 100644 (file)
@@ -308,7 +308,7 @@ def switch_branch(name):
     if not branch_exists(new_head):
         raise GitException, 'Branch "%s" does not exist' % name
 
-    tree_id = rev_parse(new_head + '^0')
+    tree_id = rev_parse(new_head + '^{commit}')
     if tree_id != get_head():
         refresh_index()
         if __run('git-read-tree -u -m', [get_head(), tree_id]) != 0: