# gitview 0.3

7 messages from 2006-02-02 to 2006-02-03. Participants: Aneesh Kumar, Junio C Hamano, Jonas Fonseca, Andreas Ericsson.
Thread: https://gitlist.dev/t/3216

## Aneesh Kumar, 2006-02-02 04:33

Subject: gitview 0.3
Message-ID: <cc723f590602012033w41b49b2ao4423707702086739@mail.gmail.com>
URL: https://gitlist.dev/e/cc723f590602012033w41b49b2ao4423707702086739%40mail.gmail.com

```
Attaching below the latest code

Changes from 0.1
* use diff-tree -m to generate the diff with --with-diff option.
* Some code cleanup
* Added --with-diff option
* Fixed typo (Dave Jones)

-aneesh

```

## Junio C Hamano, 2006-02-02 06:13

Subject: Re: gitview 0.3
Message-ID: <7vzmlauw35.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vzmlauw35.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <cc723f590602012033w41b49b2ao4423707702086739@mail.gmail.com>

```
Nice work for 0.low-number version.

On my notebook, I felt really miserable to see that the middle
band taking so much space to show rev committer timestamp and
parents.  The bottom window starts with the same information
repeated (worse, with unreadable timestamp format) and I had to
scroll all the way down to view the rest of the commit message.

If you absolutely want the middle band, maybe instead of showing
object names in "Parents" "Children" part, you can show the
one-line commit logs from them there, and pop-up the object
names along with the rest of commit log message as mouse hovers
over.

I missed "this commit is branch head of X" and "this commit is
tagged with T" markers gitk has.

Needs a bit more compact layout to be useful for me.  In short,
gitk's display does everything I want it to show in a compact
enough way and I think there is no reason not to imitate it.

Do colors of nodes have any significance?  I couldn't tell from
the UI (and I tried to figure it out without reading code --
otherwise I cannot tell if the choice of colors is intuitive).

It might match more people's expectation if --with-diff were the
default.

This patch might make merges easier to read.

-- >8 --
[PATCH] Use "diff-tree -c" to display merges a bit more readably.

--- a/gitview	2006-02-01 21:16:43.000000000 -0800
+++ b/gitview	2006-02-01 21:46:24.000000000 -0800
@@ -305,7 +305,7 @@
 		return message
 
 	def diff_tree(self):
-		fp = os.popen("git diff-tree --pretty -m -v -p " + " " + self.commit_sha1)
+		fp = os.popen("git diff-tree --pretty -c -v -p " + " " + self.commit_sha1)
 		diff = fp.read()
 		fp.close()
 

```

## Aneesh Kumar, 2006-02-02 07:15

Subject: Re: gitview 0.3
Message-ID: <cc723f590602012315p2ba6e3f5rcf34df4bdefa5cb7@mail.gmail.com>
URL: https://gitlist.dev/e/cc723f590602012315p2ba6e3f5rcf34df4bdefa5cb7%40mail.gmail.com
In-Reply-To: <7vzmlauw35.fsf@assigned-by-dhcp.cox.net>

```
On 2/2/06, Junio C Hamano <junkio@cox.net> wrote:
> Nhe choice of colors is intuitive).
>
> It might match more people's expectation if --with-diff were the
> default.
>

Done. I made it to take option --without-diff for guys like me


> This patch might make merges easier to read.
>
> -- >8 --
> [PATCH] Use "diff-tree -c" to display merges a bit more readably.
>
> --- a/gitview   2006-02-01 21:16:43.000000000 -0800
> +++ b/gitview   2006-02-01 21:46:24.000000000 -0800
> @@ -305,7 +305,7 @@
>                 return message
>
>         def diff_tree(self):
> -               fp = os.popen("git diff-tree --pretty -m -v -p " + " " + self.commit_sha1)
> +               fp = os.popen("git diff-tree --pretty -c -v -p " + " " + self.commit_sha1)
>                 diff = fp.read()
>                 fp.close()
>
>
>
>


I applied this patch . But the problem now is merge commits doesn't
show the commit messages. Adding -m also didn't help. Any suggestion

-aneesh

```

## Jonas Fonseca, 2006-02-02 12:21

Subject: [PATCH] Fix date display
Message-ID: <20060202122124.GB9756@diku.dk>
URL: https://gitlist.dev/e/20060202122124.GB9756%40diku.dk
In-Reply-To: <cc723f590602012033w41b49b2ao4423707702086739@mail.gmail.com>

```
Hello,

Here is a patch that uses the tz info for setting commit dates.

--- a/gitview	2006-02-02 12:29:05.000000000 +0100
+++ b/gitview	2006-02-02 12:28:24.000000000 +0100
@@ -31,6 +31,7 @@
     have_gtksourceview = False
     print "Running without gtksourceview module"
 
+re_ident = re.compile('(author|committer) (?P<ident>.*) (?P<epoch>\d+) (?P<tz>[+-]\d{4})')
 
 def list_to_string(args, skip):
 	count = len(args)
@@ -43,6 +44,16 @@
 
 	return str_arg
 
+def show_date(epoch, tz):
+	secs = float(epoch)
+	tzsecs = float(tz[1:3]) * 3600
+	tzsecs += float(tz[3:5]) * 60
+	if (tz[0] == "+"):
+		secs += tzsecs
+	else:
+		secs -= tzsecs
+	return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(secs))
+
 
 class CellRendererGraph(gtk.GenericCellRenderer):
 	"""Cell renderer for directed graph.
@@ -277,22 +288,15 @@
 			if (m != None):
 				continue
 
-
-			m = re.match("author", line)
-			if (m  != None ):
-				patch_author = re.split(" ", line)	
-				self.author = list_to_string(patch_author[1:-2], 0)
-				self.date = time.strftime("%Y-%m-%d %H:%M:%S",
-						time.gmtime(float(patch_author[-2])))
-				continue
-
-			m = re.match("committer", line)
-			if (m  != None ):
-				patch_committer = re.split(" ", line)	
-				self.committer = list_to_string(patch_committer[1:-2], 0)
-				self.commit_date = time.strftime("%Y-%m-%d %H:%M:%S",
-						time.gmtime(float(patch_committer[-2])))
-				continue
+			m = re_ident.match(line)
+			if (m != None):
+				date = show_date(m.group('epoch'), m.group('tz'))
+				if m.group(1)[0] == 'a':
+					self.author = m.group('ident')
+					self.date = date
+				else:
+					self.committer = m.group('ident')
+					self.commit_date = date
 
 	def get_message(self, with_diff=0):
 		if (with_diff == 1):
-- 
Jonas Fonseca

```

## Aneesh Kumar, 2006-02-02 16:03

Subject: Re: gitview 0.3
Message-ID: <cc723f590602020803u72bdff2ek95fba2ea30970170@mail.gmail.com>
URL: https://gitlist.dev/e/cc723f590602020803u72bdff2ek95fba2ea30970170%40mail.gmail.com
In-Reply-To: <7vzmlauw35.fsf@assigned-by-dhcp.cox.net>

```
On 2/2/06, Junio C Hamano <junkio@cox.net> wrote:
> Nice work for 0.low-number version.
>
> On my notebook, I felt really miserable to see that the middle
> band taking so much space to show rev committer timestamp and
> parents.  The bottom window starts with the same information
> repeated (worse, with unreadable timestamp format) and I had to
> scroll all the way down to view the rest of the commit message.

I have rearranged the default with respect these frames. Attaching the
code below. Let me know if it is ok.


>
> If you absolutely want the middle band, maybe instead of showing
> object names in "Parents" "Children" part, you can show the
> one-line commit logs from them there, and pop-up the object
> names along with the rest of commit log message as mouse hovers
> over.
>
> I missed "this commit is branch head of X" and "this commit is
> tagged with T" markers gitk has.
>

I am planning to add this. I am yet to learn fully how to use the
cairo API. gitview was partly my attempt to learn pygtk.


> Needs a bit more compact layout to be useful for me.  In short,
> gitk's display does everything I want it to show in a compact
> enough way and I think there is no reason not to imitate it.
>

One thing i didn't like with gitk was the looks. And the diff window
was so shaded i had to put real effort to read the contents. May be i
didn't had necessary fonts. I don't know


> Do colors of nodes have any significance?  I couldn't tell from
> the UI (and I tried to figure it out without reading code --
> otherwise I cannot tell if the choice of colors is intuitive).
>

One parent of the child follows the same colour. It in a way let one
figure out at what point branch happened and at what point they merged
back.


> It might match more people's expectation if --with-diff were the
> default.
>

This is done. I am attaching the full code below. Can you get the
gitview added git repository so that next time onwards i need to send
only the diff.

> This patch might make merges easier to read.
>
> -- >8 --
> [PATCH] Use "diff-tree -c" to display merges a bit more readably.
>
> --- a/gitview   2006-02-01 21:16:43.000000000 -0800
> +++ b/gitview   2006-02-01 21:46:24.000000000 -0800
> @@ -305,7 +305,7 @@
>                 return message
>
>         def diff_tree(self):
> -               fp = os.popen("git diff-tree --pretty -m -v -p " + " " + self.commit_sha1)
> +               fp = os.popen("git diff-tree --pretty -c -v -p " + " " + self.commit_sha1)
>                 diff = fp.read()
>                 fp.close()
>
>
>
>


I am using the --cc flag and if i don't have any message i get the
commit message only using git cat-file. I guess that is ok

-aneesh

```

## Junio C Hamano, 2006-02-03 05:03

Subject: Re: gitview 0.3
Message-ID: <7vzml9kp9q.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vzml9kp9q.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <cc723f590602020803u72bdff2ek95fba2ea30970170@mail.gmail.com>

```
Aneesh Kumar <aneesh.kumar@gmail.com> writes:

> ... Can you get the gitview added git repository so that next
> time onwards i need to send only the diff.

We _could_ make a contrib/gitview directory to keep it there,
and as somebody else comes up with a new interesting git
application, add a new directory in contrib/ to expand that
area.

But personally I am not enthused about keeping other peoples'
projects in git.git tree [*1*].  I'd rather see you start your
own public repository, propagate your changes from there, and
run it as your own project.

Even though it is currently a single file 'project', you will
want to add more stuff, maybe splitting the code to use your own
*.py module to import into the main program, and add *.c files
to interface with the lower level and Makefile to describe the
build rules once we start libifying git.  I suspect we are all
better off if we keep separate projects separate in the long
run.

Somebody (I think it was Sean Estabrooks but I may be mistaken)
once offered to host git projects at a site he controls.  I
wonder if you can get him interested...


[Footnote]

*1* I was not too happy to see gitk merged in with "the coolest
merge ever" myself, but that was done before my time.  "Not too
happy" does not necessarily mean I object to it.  All things
considered I think it was a good thing: (1) as a showcase of how
cool a merge can be, it was a good demonstration; (2) coming
with a repository browser usable out-of-box with minimum
dependencies was a good thing (tcl/tk is pretty much available
universally for easy install); (3) it is a good example program
of how a repository browser can be done.

```

## Andreas Ericsson, 2006-02-03 09:20

Subject: Re: gitview 0.3
Message-ID: <43E32075.9010507@op5.se>
URL: https://gitlist.dev/e/43E32075.9010507%40op5.se
In-Reply-To: <7vzml9kp9q.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:
> 
> Somebody (I think it was Sean Estabrooks but I may be mistaken)
> once offered to host git projects at a site he controls.  I
> wonder if you can get him interested...
> 

I've got space for this. If anyone's interested, send me an email off-list.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```
