summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authoraneesh.kumar@gmail.com <aneesh.kumar@gmail.com>2006-02-21 16:00:04 +0530
committerJunio C Hamano <junkio@cox.net>2006-02-21 18:38:11 -0800
commit5301eee92ceb1c349ea8090a4d8aa3aa70c4abed (patch)
treebf780d179597930d1d5d935b1b10e5f4bd291ffe /contrib
parentc8af25ca0157146de59b992c1f961f1af8465995 (diff)
downloadgit-5301eee92ceb1c349ea8090a4d8aa3aa70c4abed.tar.gz
gitview: Read tag and branch information using git ls-remote
This fix the below bug Junio C Hamano <junkio@cox.net> writes: > > It does not work in my repository, since you do not seem to > handle branch and tag names with slashes in them. All of my > topic branches live in directories with two-letter names > (e.g. ak/gitview). Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/gitview/gitview50
1 files changed, 14 insertions, 36 deletions
diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview
index 5862fcca41..b75b39e5fc 100755
--- a/contrib/gitview/gitview
+++ b/contrib/gitview/gitview
@@ -56,20 +56,6 @@ def show_date(epoch, tz):
return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(secs))
-def get_sha1_from_tags(line):
- fp = os.popen("git cat-file -t " + line)
- entry = string.strip(fp.readline())
- fp.close()
- if (entry == "commit"):
- return line
- elif (entry == "tag"):
- fp = os.popen("git cat-file tag "+ line)
- entry = string.strip(fp.readline())
- fp.close()
- obj = re.split(" ", entry)
- if (obj[0] == "object"):
- return obj[1]
- return None
class CellRendererGraph(gtk.GenericCellRenderer):
"""Cell renderer for directed graph.
@@ -465,32 +451,24 @@ class GitView:
respective sha1 details """
self.bt_sha1 = { }
+ ls_remote = re.compile('^(.{40})\trefs/([^^]+)(?:\\^(..))?$');
git_dir = os.getenv("GIT_DIR")
if (git_dir == None):
git_dir = ".git"
- #FIXME the path seperator
- ref_files = os.listdir(git_dir + "/refs/tags")
- for file in ref_files:
- fp = open(git_dir + "/refs/tags/"+file)
- sha1 = get_sha1_from_tags(string.strip(fp.readline()))
- try:
- self.bt_sha1[sha1].append(file)
- except KeyError:
- self.bt_sha1[sha1] = [file]
- fp.close()
-
-
- #FIXME the path seperator
- ref_files = os.listdir(git_dir + "/refs/heads")
- for file in ref_files:
- fp = open(git_dir + "/refs/heads/" + file)
- sha1 = get_sha1_from_tags(string.strip(fp.readline()))
- try:
- self.bt_sha1[sha1].append(file)
- except KeyError:
- self.bt_sha1[sha1] = [file]
- fp.close()
+ fp = os.popen('git ls-remote ' + git_dir)
+ while 1:
+ line = string.strip(fp.readline())
+ if line == '':
+ break
+ m = ls_remote.match(line)
+ if not m:
+ continue
+ (sha1, name) = (m.group(1), m.group(2))
+ if not self.bt_sha1.has_key(sha1):
+ self.bt_sha1[sha1] = []
+ self.bt_sha1[sha1].append(name)
+ fp.close()
def construct(self):