git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustav Hållberg" <gustav@gmail.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: "David Kågedal" <davidk@lysator.liu.se>,
	kha@treskal.com, git@vger.kernel.org
Subject: [PATCH 1/2] Repository.rev_parse: support commits, trees, and blobs
Date: Mon, 24 May 2010 20:52:19 +0200	[thread overview]
Message-ID: <20100524185219.30884.66896.stgit@sambuntu> (raw)
In-Reply-To: <20100524184908.30884.65042.stgit@sambuntu>


---
 stgit/lib/git.py |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/stgit/lib/git.py b/stgit/lib/git.py
index 65d2a6c..899c1a2 100644
--- a/stgit/lib/git.py
+++ b/stgit/lib/git.py
@@ -581,13 +581,15 @@ class Repository(RunWithEnv):
     refs = property(lambda self: self.__refs)
     def cat_object(self, sha1):
         return self.run(['git', 'cat-file', '-p', sha1]).raw_output()
-    def rev_parse(self, rev, discard_stderr = False):
+    def rev_parse(self, rev, discard_stderr = False, object_type = 'commit'):
+        assert object_type in ('commit', 'tree', 'blob')
+        getter = getattr(self, 'get_' + object_type)
         try:
-            return self.get_commit(self.run(
-                    ['git', 'rev-parse', '%s^{commit}' % rev]
+            return getter(self.run(
+                    ['git', 'rev-parse', '%s^{%s}' % (rev, object_type)]
                     ).discard_stderr(discard_stderr).output_one_line())
         except run.RunException:
-            raise RepositoryException('%s: No such revision' % rev)
+            raise RepositoryException('%s: No such %s' % (rev, object_type))
     def get_blob(self, sha1):
         return self.__blobs[sha1]
     def get_tree(self, sha1):

  reply	other threads:[~2010-05-24 18:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-16 17:33 [StGit PATCH] edit: Allow setting git tree SHA1 of a patch Gustav Hållberg
2010-05-17 17:14 ` Karl Wiberg
2010-05-21 12:37 ` Catalin Marinas
2010-05-21 13:59   ` David Kågedal
2010-05-21 15:16     ` Catalin Marinas
2010-05-21 15:29       ` David Kågedal
2010-05-21 15:32       ` Gustav Hållberg
2010-05-21 15:58         ` Catalin Marinas
2010-05-21 17:48           ` David Kågedal
2010-05-21 18:45           ` Gustav Hållberg
2010-05-24 18:52           ` [PATCH 0/2] Setting git tree of a patch (improved version) Gustav Hållberg
2010-05-24 18:52             ` Gustav Hållberg [this message]
2010-05-24 18:52             ` [PATCH 2/2] edit: Allow setting git tree of a patch Gustav Hållberg
2010-05-25 12:26             ` [PATCH 0/2] Setting git tree of a patch (improved version) Catalin Marinas
2010-05-26 15:34               ` Gustav Hållberg
2010-05-26 21:18                 ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100524185219.30884.66896.stgit@sambuntu \
    --to=gustav@gmail.com \
    --cc=catalin.marinas@gmail.com \
    --cc=davidk@lysator.liu.se \
    --cc=git@vger.kernel.org \
    --cc=kha@treskal.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).