Git development
 help / color / mirror / Atom feed
* Re: [RFC] Third round of support for cloning submodules
From: Sven Verdoolaege @ 2007-05-20 21:09 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Junio C Hamano, git
In-Reply-To: <20070520205444.GC25462@steel.home>

On Sun, May 20, 2007 at 10:54:44PM +0200, Alex Riesen wrote:
> Sven Verdoolaege, Sun, May 20, 2007 21:59:30 +0200:
> > > I am very worried about this big red switch that says "all
> > > subprojects to be cloned and checked out, or nothing".  I think
> > > this would not work well with projects that truly need
> > > superproject support (i.e. very large ones, where most people
> > > would not want to clone and check out every single subproject).
> > 
> > It's pretty easy to add a "submodule.*.skip" or "submodule.*.ignore".
> > Since the subcloning only happens at checkout, you could set these
> > before doing a checkout.
> 
> And set them back after doing the checkout?

What do you mean?  Why would you set them back?
I guess I'm missing something.

> Me too. I actually believe it is the only way to do it. How can you
> checkout a subproject to something else (to what a branch may point)
> and to what the tree of superproject has? On the other side (in
> subproject) - why are you, the superproject, allowed to screw the
> references of the subproject?! It is independent, isn't it?!

Well... the subproject as a whole is independent of the superproject,
but the checkout in the superproject is not entirely independent.

> > >  - What would we do when the subproject working tree is not
> > >    clean?
> > 
> > I was planning on adding a --dry-run to git-checkout.
> > The superproject would run this in each subproject before
> > doing the actual checkout of the superproject.
> 
> Why not do exactly what we do now? Pass "-m" down to it, if it was
> given to the top-level git-checkout.

We want to be sure that all (selected) subprojects can be updated before
updating any, no?

skimo

^ permalink raw reply

* Re: [PATCH] allow commands to be executed in submodules
From: Martin Waitz @ 2007-05-20 21:08 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Junio C Hamano, git
In-Reply-To: <20070520205933.GD25462@steel.home>

[-- Attachment #1: Type: text/plain, Size: 935 bytes --]

hoi :)

On Sun, May 20, 2007 at 10:59:33PM +0200, Alex Riesen wrote:
> Is there multiple places? Is it hard to create a specific function out
> of a generic one? (which can be used from other places and your
> specific can't and we would need the generic one anyway).

you can add a specific new function for submodules, dropping the
nice property of child_process that you only have to initialize a few
fields and then can run the command.

> "Generic" is not about "multiple places". Generic is about "general"
> as opposite to "specific". Gives you flexibility and wider application
> range.

Generic code and abstractions only make sense when they are _useful_.
Lets not overengineer it.  If we later see that we need more, then
so be it.  KISS.

But now lets go on and don't discuss about such details.
I'm happy if I can run commands in submodules and don't care about the
actual code.

-- 
Martin Waitz

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: git log -S problem
From: Junio C Hamano @ 2007-05-20 21:05 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git
In-Reply-To: <200705202115.39325.johannes.sixt@telecom.at>

Johannes Sixt <johannes.sixt@telecom.at> writes:

> There is something odd with -S of git log. Try this in your git.git:
>
> $ git log --pretty=oneline -Sbuiltin-merge-base -- Makefile 
> 71dfbf224ff980f4085f75868dc409118418731e Make merge-base a built-in.
>
> $ git log --pretty=oneline -Smerge-base -- Makefile
> e468305a954d95a26bfcdec3bc6e4bd477d95676 [PATCH] Remove the explicit ...
> a3df180138b85a603656582bde6df757095618cf Rename git core commands ...
> cef661fc799a3a13ffdea4a3f69f1acd295de53d Add support for alternate ...
> e590d694ead8d50c2afc7086161d4ddc5d907655 Add more header dependencies.
> 6683463ed6b2da9eed309c305806f9393d1ae728 Do a very simple "merge-base"...
>
> $ git version
> git version 1.5.2
>
> I had expected that the set of commits found by the second search string are a 
> proper superset of those found by the first one. What's wrong here? Why does 
> a search for 'merge-base' not find occurences of 'builtin-merge-base'?

71dfbf224 removes one line that has "git-merge-base$X" and adds
one line that has "builtin-merge-base.o".  If you count the
number of occurences of substring "builtin-merge-base" in the
preimage and the postimage, you see one addition.  If you count
the same for substring "merge-base", the net difference is 0.

^ permalink raw reply

* Re: [PATCH] allow commands to be executed in submodules
From: Alex Riesen @ 2007-05-20 20:59 UTC (permalink / raw)
  To: Martin Waitz; +Cc: Junio C Hamano, git
In-Reply-To: <20070520204801.GH5412@admingilde.org>

Martin Waitz, Sun, May 20, 2007 22:48:02 +0200:
> Do we really have so many places where we want to execute commands
> in a different directory or with different environment?  Is it worth
> keeping run-command generic and having to introduce knowledge about
> how to run submodule commands in multiple places?

Is there multiple places? Is it hard to create a specific function out
of a generic one? (which can be used from other places and your
specific can't and we would need the generic one anyway).

"Generic" is not about "multiple places". Generic is about "general"
as opposite to "specific". Gives you flexibility and wider application
range.

^ permalink raw reply

* Re: [PATCH] Teach 'git-apply --whitespace=strip' to remove empty lines at the end of file
From: Marco Costalba @ 2007-05-20 20:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List
In-Reply-To: <7vd50vl30r.fsf@assigned-by-dhcp.cox.net>

On 5/20/07, Junio C Hamano <junkio@cox.net> wrote:
> "Marco Costalba" <mcostalba@gmail.com> writes:
>
> >> >               if (offset >= 0) {
> >> > +
> >> > +                     if (desc->size - oldsize - offset == 0) /* end of file? */
> >> > +                             newsize -= trailing_added_lines;
> >> > +
> >> >                       int diff = newsize - oldsize;
> >> >                       unsigned long size = desc->size + diff;
> >> >                       unsigned long alloc = desc->alloc;
> >>

>
> Sorry I forgot to mention that that is "trivial" so there is no
> reason to resend.  I don't expect me doing much git stuff for
> the rest of the day, but you'll hear from me about this patch
> later (hopefully it would appear on 'next' -- we'll see).
>

Ok. Thanks for your help.

P.S: I don't find a trivial way to avoid adding more lines then
removed, the shortest trick I can find is

int eof = (desc->size - oldsize - offset == 0);
int diff = newsize - oldsize - eof * trailing_added_lines;
unsigned long size = desc->size + diff;
unsigned long alloc = desc->alloc;

newsize -= eof * trailing_added_lines;


But is not as elegant as the original.

^ permalink raw reply

* Re: [RFC] Third round of support for cloning submodules
From: Alex Riesen @ 2007-05-20 20:54 UTC (permalink / raw)
  To: skimo; +Cc: Junio C Hamano, git
In-Reply-To: <20070520195930.GX942MdfPADPa@greensroom.kotnet.org>

Sven Verdoolaege, Sun, May 20, 2007 21:59:30 +0200:
> > I am very worried about this big red switch that says "all
> > subprojects to be cloned and checked out, or nothing".  I think
> > this would not work well with projects that truly need
> > superproject support (i.e. very large ones, where most people
> > would not want to clone and check out every single subproject).
> 
> It's pretty easy to add a "submodule.*.skip" or "submodule.*.ignore".
> Since the subcloning only happens at checkout, you could set these
> before doing a checkout.

And set them back after doing the checkout? And so for each and every
checkout operation? I suggest you try checkout something like KDE a
few times (well, assuming KDE is split in submodules. It isn't yet).
The point is - it is annoying. And if it is annoying, it wont be used
(as branches in CVS and merging in SVN).

> > The more important issue I think is at what point in the
> > superproject operation does a recursive checkout in a subproject
> > should happen, and how we should do the checkout.  Issues I can
> > think of offhand are (no way exhaustive):
> > 
> >  - Do we checkout a branch? if so which one?
> > 
> >  - Do we detach HEAD if the commit named by the superproject
> >    tree is not at the tip of the current branch of subproject?
> >    do we detach always even if the commit is at the tip?
> 
> I thought there was a consensus to detach the HEAD.
> I don't have a strong opinion on this issue, but a detached
> HEAD seems the most appropriate to me.

Me too. I actually believe it is the only way to do it. How can you
checkout a subproject to something else (to what a branch may point)
and to what the tree of superproject has? On the other side (in
subproject) - why are you, the superproject, allowed to screw the
references of the subproject?! It is independent, isn't it?!

> >  - What would we do when the subproject working tree is not
> >    clean?
> 
> I was planning on adding a --dry-run to git-checkout.
> The superproject would run this in each subproject before
> doing the actual checkout of the superproject.

Why not do exactly what we do now? Pass "-m" down to it, if it was
given to the top-level git-checkout.

^ permalink raw reply

* Re: [StGit PATCH 1/2] Update the bash prompt from 'applied' instead of  the obsolete 'current'
From: Yann Dirson @ 2007-05-20 20:46 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: 20070506150852.8985.98091.stgit, git
In-Reply-To: <20070520200403.14633.26644.stgit@lathund.dewire.com>

Note that "tail -1" gives a warning with newer versions, "tail -n 1"
should be the proper call.

Also I'm not sure it is a good way to look at "applied" file, since
Karl IIRC has plans to change this.  Better call "stg top" and not
touch that again :)

On Sun, May 20, 2007 at 10:04:03PM +0200, Robin Rosenberg wrote:
> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
> ---
> 
>  contrib/stgbashprompt.sh |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/contrib/stgbashprompt.sh b/contrib/stgbashprompt.sh
> index 16bb39b..7c5dc76 100755
> --- a/contrib/stgbashprompt.sh
> +++ b/contrib/stgbashprompt.sh
> @@ -8,8 +8,8 @@ if [ "$PS1" ]; then
>  		git_dir=$(git-rev-parse --git-dir 2> /dev/null) || return
>  		ref=$(git-symbolic-ref HEAD 2> /dev/null) || return
>  		br=${ref#refs/heads/}
> -		top=$(cat $git_dir/patches/$br/current 2>/dev/null) \
> -			&& top="/$top"
> +		top=$(tail -1 $git_dir/patches/$br/applied 2>/dev/null) \
> +			&& top="/$top";
>  		echo "[$br$top]"
>  	}
>  	PS1='\u@\h:$(__prompt_git)\W\$ '
> 
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> !DSPAM:4650aff673931961316905!
> 

^ permalink raw reply

* Re: [PATCH] allow commands to be executed in submodules
From: Martin Waitz @ 2007-05-20 20:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Alex Riesen, git
In-Reply-To: <7vhcq7mjxn.fsf@assigned-by-dhcp.cox.net>

[-- Attachment #1: Type: text/plain, Size: 709 bytes --]

hoi :)

On Sun, May 20, 2007 at 11:25:24AM -0700, Junio C Hamano wrote:
> Sounds useful and more generic.

I explicitly wanted to have a method to execute one command in
the environment of a submodule.  That way we can update it in
one place if we later add more environment variables which
influence the repository.

Do we really have so many places where we want to execute commands
in a different directory or with different environment?  Is it worth
keeping run-command generic and having to introduce knowledge about
how to run submodule commands in multiple places?

That said I don't have any strong feeling about it, as long as one
or the other patch is applied.

-- 
Martin Waitz

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH] Teach mailsplit about Maildir's
From: Fernando J. Pereda @ 2007-05-20 20:44 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <20070520203534.GB25462@steel.home>

On Sun, May 20, 2007 at 10:35:34PM +0200, Alex Riesen wrote:
> Fernando J. Pereda, Sun, May 20, 2007 21:00:24 +0200:
> > On Sun, May 20, 2007 at 08:49:59PM +0200, Alex Riesen wrote:
> > > Junio C Hamano, Sun, May 20, 2007 20:36:25 +0200:
> > > > > +IMPORTANT: Maildir splitting relies upon filenames being sorted to output
> > > > > +patches in the correct order.
> > > > 
> > > > I am sure there are many users who uses Maildir layout on this
> > > > list.  Happy with this patch?  Please speak out.
> > > 
> > > I do use maildirs, but I have a suggestion: --maildir or something, to
> > > create a non-existing maildir and split into it, so that the user does
> > > not have to pre-create it.
> > 
> > I can't think of a use case for this...
> > 
> 
> You actually enjoy typing "mkdir tmp && git mailsplit tmp"?

Well, my mail client creates Maildirs for me... so I still don't see why
would you do that. I copy mails with patches to a new maildir and run
git am there...

As I said I can't think of a use case for your suggestion.


- ferdy

-- 
Fernando J. Pereda Garcimartín
20BB BDC3 761A 4781 E6ED  ED0B 0A48 5B0C 60BD 28D4

^ permalink raw reply

* Re: [PATCH] Teach 'git-apply --whitespace=strip' to remove empty lines at the end of file
From: Marco Costalba @ 2007-05-20 20:44 UTC (permalink / raw)
  To: Frank Lichtenheld; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <20070520191718.GI4085@planck.djpig.de>

On 5/20/07, Frank Lichtenheld <frank@lichtenheld.de> wrote:
> > >
> > >But we have kept our sources -Wdeclaration-after-statement
> > >clean so far
> >
> > ??????
> >
> > Wie bitte?
>
> man gcc:
>
> -Wdeclaration-after-statement (C only)
>    Warn when a declaration is found after a statement in a block.
>

Just for my personal knowledge, what's the meaning of this apparently
non-sense kind of warning?

Thanks
Marco

^ permalink raw reply

* Re: [PATCH] rev-list: '--indent' oneline output
From: Steffen Prohaska @ 2007-05-20 20:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, bfields, torvalds
In-Reply-To: <7vveenl4u4.fsf@assigned-by-dhcp.cox.net>


On May 20, 2007, at 8:36 PM, Junio C Hamano wrote:

> Steffen Prohaska <prohaska@zib.de> writes:
>
>> Summaries in oneline output are indented to show the location of
>> parents in merge commits. Indentation level is computed as the
>> smallest sum of parent locations along all paths that reach the
>> commit.
>>
>> As a result, the output of
>>     git-rev-list --pretty=oneline --topo-order --indent
>> is formatted in a way that resembles merge summaries. All commits  
>> that
>> were pulled from a branch are indented with one additional space  
>> below
>> the summary of the merge commit.
>
> I would have expected this kind of UI level tweak to be done not
> as a rev-list feature, but the subject of the e-mail to read
> something like "--pretty=oneline: allow indentation levels",
> i.e. wouldn't the feature apply not just rev-list but also
> git-log?

It's only a proof of concept. I do not expect to see it added in
the current form. I'm not yet convinced if it's really a useful feature.

I'm also not sure if changing 'struct commit' is a good idea.
gitk is able to display the commit graph by parsing output of the
existing git-rev-list. It should be possible to do similar for log
formatting without changing 'struct commit'.

- Steffen

^ permalink raw reply

* Re: [PATCH] Teach mailsplit about Maildir's
From: Alex Riesen @ 2007-05-20 20:35 UTC (permalink / raw)
  To: Fernando J. Pereda, Junio C Hamano, Git Mailing List
In-Reply-To: <20070520190024.GE13197@ferdyx.org>

Fernando J. Pereda, Sun, May 20, 2007 21:00:24 +0200:
> On Sun, May 20, 2007 at 08:49:59PM +0200, Alex Riesen wrote:
> > Junio C Hamano, Sun, May 20, 2007 20:36:25 +0200:
> > > > +IMPORTANT: Maildir splitting relies upon filenames being sorted to output
> > > > +patches in the correct order.
> > > 
> > > I am sure there are many users who uses Maildir layout on this
> > > list.  Happy with this patch?  Please speak out.
> > 
> > I do use maildirs, but I have a suggestion: --maildir or something, to
> > create a non-existing maildir and split into it, so that the user does
> > not have to pre-create it.
> 
> I can't think of a use case for this...
> 

You actually enjoy typing "mkdir tmp && git mailsplit tmp"?

^ permalink raw reply

* Re: merge summaries
From: Robin Rosenberg @ 2007-05-20 20:34 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: J. Bruce Fields, Junio C Hamano, Steffen Prohaska,
	Git Mailing List
In-Reply-To: <alpine.LFD.0.98.0705181611520.3890@woody.linux-foundation.org>

lördag 19 maj 2007 skrev Linus Torvalds:
> 
> On Fri, 18 May 2007, J. Bruce Fields wrote:
> > 
> > I never quite understood what they're for--do they add any information
> > not already available in the history?  If not, and if people still find
> > them helpful anyway, then I dunno, it looks like a sign of some sort of
> > failure of our history display tools.
> 
> I don't think they add much in the case of a graphical viewer, but for 
> "git log", it does make it look nicer..

It is nice for git-cvsexportcommit too. 

-- robin

^ permalink raw reply

* [PATCH 5/5] gitweb: Incremental blame
From: Martin Koegler @ 2007-05-20 20:23 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git, Martin Koegler
In-Reply-To: <11796926122089-git-send-email-mkoegler@auto.tuwien.ac.at>

Rewrite ontop of diff patches + some performance tuning.
---
The first chunk is the new version of the link rewriting for git-blame.
It does not need the blamelink class.

As gitweb.js is included in each page (and I didn't wanted to add a second JavaScript file),
I added the content of blame.js at the end of gitweb.js.

I also tried some optimizations. In IceWeasel 2.0.0.3 (= FireFox), the blame of sha1_file.c
needs now 33 instead of 46 seconds on my computer.

The "optimizations" are not tested in other browsers. According to my experience,
I expect that the incremental blame in IE will be slower then in Mozilla.

 gitweb/gitweb.js   |  181 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gitweb/gitweb.perl |   92 ++++++++++++++++++++++++---
 2 files changed, 264 insertions(+), 9 deletions(-)

diff --git a/gitweb/gitweb.js b/gitweb/gitweb.js
index cacab5a..001fac6 100644
--- a/gitweb/gitweb.js
+++ b/gitweb/gitweb.js
@@ -259,6 +259,11 @@ function GitAddLinks ()
     {
       var link = links[i];
       var url = splitGitURL (link.href);
+      if (url.a == "blame")
+	{
+	  url.a = "blame_incremental";
+	  link.href = url.ToURL();
+	}
       if (link.innerHTML == 'commit' || link.innerHTML == 'tag')
 	{
 	  if (!url.h)
@@ -296,3 +301,179 @@ function GitAddLinks ()
 }
 
 window.onload = GitAddLinks;
+
+// Blame Javascript functions
+// Copyright (C) 2007, Fredrik Kuivinen <frekui@gmail.com>
+// modifed by Martin Koegler <mkoegler@auto.tuwien.ac.at>
+
+function createRequestObject() {
+	var ro;
+	if (window.XMLHttpRequest) {
+		ro = new XMLHttpRequest();
+	} else {
+		ro = new ActiveXObject("Microsoft.XMLHTTP");
+	}
+	return ro;
+}
+
+var http;
+var baseUrl;
+
+// 'commits' is an associative map. It maps SHA1s to Commit objects.
+var commits = new Object();
+
+function Commit(sha1)
+{
+	this.sha1 = sha1;
+}
+
+function zeroPad(n)
+{
+	if (n < 10)
+		return '0' + n;
+	else
+		return n.toString();
+}
+
+function handleLine(commit)
+{
+	/* This is the structure of the HTML fragment we are working
+	   with:
+	   
+	   <tr id="l123" class="light2">
+	   <td class="sha1" title="">
+	   <a href=""></a>
+	   </td>
+	   <td class="linenr">
+	   <a class="linenr" href="">123</a>
+	   </td>
+	   <td class="pre"># times (my ext3 doesn&#39;t).</td>
+	   </tr>
+	 */
+	var tr = document.getElementById('l'+commit.resline);
+	var linkurl = baseUrl + ';a=blame_incremental;hb=' + commit.sha1
+	  + ';f=' + commit.filename + '#l' + commit.srcline;
+
+	var date = new Date();
+	date.setTime(commit.authorTime * 1000);
+	var dateStr = date.getUTCFullYear() + '-'
+	  + zeroPad(date.getUTCMonth()+1) + '-'
+	  + zeroPad(date.getUTCDate());
+	var timeStr = zeroPad(date.getUTCHours()) + ':'
+	  + zeroPad(date.getUTCMinutes()) + ':'
+	  + zeroPad(date.getUTCSeconds());
+	var title = commit.author + ', ' + dateStr + ' ' + timeStr;
+
+	for (var i = 0; i < commit.numlines; i++) {
+		tr.firstChild.title = title;
+		var shaAnchor = tr.firstChild.firstChild;
+		if (i == 0) {
+			shaAnchor.href = baseUrl + ';a=commit;h=' + commit.sha1;
+			shaAnchor.innerHTML = commit.sha1.substr(0, 8);
+		} else {
+		  if (shaAnchor.innerHTML != '')
+		    shaAnchor.innerHTML = '';
+		}
+
+		tr.firstChild.nextSibling.firstChild.href = linkurl;
+
+		tr = tr.nextSibling;
+		while (tr && tr.nodeType == 3)
+		  tr = tr.nextSibling;
+	}
+}
+
+function fixColors()
+{
+	var colorClasses = ['light2', 'dark2'];
+	var tr = document.getElementById('l1');
+	var colorClass = 0;
+
+	while (tr) {
+		if (tr.firstChild.firstChild.innerHTML != '')
+			colorClass = (colorClass+1)%2;
+
+		if (tr.className != colorClasses[colorClass])
+		  tr.className = colorClasses[colorClass];
+		tr = tr.nextSibling;
+		while (tr && tr.nodeType == 3)
+		  tr = tr.nextSibling;
+	}
+}
+
+var prevDataLength = -1;
+var nextLine = 0;
+var inProgress = false;
+
+var curCommit = new Commit();
+
+function handleResponse() {
+	if (http.readyState != 4 && http.readyState != 3)
+		return;
+
+	// In konqueror http.responseText is sometimes null here...
+	if (http.responseText === null)
+		return;
+
+	if (inProgress)
+		return;
+	else
+		inProgress = true;
+
+	while (prevDataLength != http.responseText.length) {
+		if (http.readyState == 4
+		    && prevDataLength == http.responseText.length) {
+			break;
+		}
+
+		prevDataLength = http.responseText.length;
+		var response = http.responseText.substring(nextLine);
+		var lines = response.split('\n');
+		nextLine = nextLine + response.lastIndexOf('\n') + 1;
+		if (response[response.length-1] != '\n') {
+			lines.pop();
+		}
+
+		for (var i = 0; i < lines.length; i++) {
+			var split = lines[i].split(' ');
+			if (split.length == 4 && split[0].length == 40) {
+				var sha1 = split[0];
+				var c = commits[sha1];
+				if (!c) {
+					c = new Commit(sha1);
+					commits[sha1] = c;
+				}
+
+				c.srcline = split[1];
+				c.resline = split[2];
+				c.numlines = split[3];
+				curCommit = c;
+			} else {
+				var info = split[0];
+				var data = lines[i].substr (info.length + 1);
+				if (info == 'filename') {
+					curCommit.filename = data;
+					handleLine(curCommit);
+				} else if (info == 'author') {
+					curCommit.author = data;
+				} else if (info == 'author-time') {
+					curCommit.authorTime = parseInt(data);
+				}
+			}
+		}
+	}
+
+	if (http.readyState == 4 && prevDataLength == http.responseText.length)
+		fixColors();
+
+	inProgress = false;
+}
+
+function startBlame(blamedataUrl, bUrl)
+{
+	baseUrl = bUrl;
+	http = createRequestObject();
+	http.open('get', blamedataUrl);
+	http.onreadystatechange = handleResponse;
+	http.send(null);
+}
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index f59a4b5..45787a6 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -462,6 +462,8 @@ $git_dir = "$projectroot/$project" if $project;
 # dispatch
 my %actions = (
 	"blame" => \&git_blame2,
+	"blame_incremental" => \&git_blame_incremental,
+	"blame_data" => \&git_blame_data,
 	"blobdiff" => \&git_blobdiff,
 	"blobdiff_plain" => \&git_blobdiff_plain,
 	"blob" => \&git_blob,
@@ -562,7 +564,7 @@ sub href(%) {
 			push @result, $symbol . "=" . esc_param($params{$name});
 		}
 	}
-	$href .= "?" . join(';', @result) if scalar @result;
+	$href .= "?" . join(';', @result) if $params{-partial_query} or scalar @result;
 
 	return $href;
 }
@@ -3517,7 +3519,47 @@ sub git_tag {
 	git_footer_html();
 }
 
-sub git_blame2 {
+sub git_blame_data {
+	my $fd;
+	my $ftype;
+
+	my ($have_blame) = gitweb_check_feature('blame');
+	if (!$have_blame) {
+		die_error('403 Permission denied', "Permission denied");
+	}
+	die_error('404 Not Found', "File name not defined") if (!$file_name);
+	$hash_base ||= git_get_head_hash($project);
+	die_error(undef, "Couldn't find base commit") unless ($hash_base);
+	my %co = parse_commit($hash_base)
+		or die_error(undef, "Reading commit failed");
+	if (!defined $hash) {
+		$hash = git_get_hash_by_path($hash_base, $file_name, "blob")
+			or die_error(undef, "Error looking up file");
+	}
+	$ftype = git_get_type($hash);
+	if ($ftype !~ "blob") {
+		die_error("400 Bad Request", "Object is not a blob");
+	}
+	open ($fd, "-|", git_cmd(), "blame", '--incremental', $hash_base, '--',
+	      $file_name)
+		or die_error(undef, "Open git-blame --incremental failed");
+
+	print $cgi->header(-type=>"text/plain", -charset => 'utf-8',
+	                   -status=> "200 OK");
+
+	while(<$fd>) {
+ 	  if (/^([0-9a-f]{40}) ([0-9]+) ([0-9]+) ([0-9]+)/ or
+	     /^author-time |^author |^filename /) {
+ 	    print;
+	  }
+	}
+
+	close $fd or print "Reading blame data failed\n";
+}
+
+sub git_blame_common {
+	my ($type) = @_;
+
 	my $fd;
 	my $ftype;
 
@@ -3536,11 +3578,16 @@ sub git_blame2 {
 	}
 	$ftype = git_get_type($hash);
 	if ($ftype !~ "blob") {
-		die_error('400 Bad Request', "Object is not a blob");
+		die_error("400 Bad Request", "Object is not a blob");
+	}
+	if ($type eq 'incremental') {
+		open ($fd, "-|", git_cmd(), 'cat-file', 'blob', $hash)
+			or die_error(undef, "Open git-cat-file failed");
+	} else {
+		open ($fd, "-|", git_cmd(), 'blame', '-p', '--',
+		      $file_name, $hash_base)
+			or die_error(undef, "Open git-blame failed");
 	}
-	open ($fd, "-|", git_cmd(), "blame", '-p', '--',
-	      $file_name, $hash_base)
-		or die_error(undef, "Open git-blame failed");
 	git_header_html();
 	my $formats_nav =
 		$cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
@@ -3564,9 +3611,19 @@ sub git_blame2 {
 <tr><th>Commit</th><th>Line</th><th>Data</th></tr>
 HTML
 	my %metainfo = ();
-	while (1) {
-		$_ = <$fd>;
-		last unless defined $_;
+	my $linenr = 0;
+	while (<$fd>) {
+		chomp;
+		if ($type eq 'incremental') {
+			# Empty stage with just the file contents
+			$linenr += 1;
+			print "<tr id=\"l$linenr\" class=\"light2\">";
+			print '<td class="sha1"><a href=""></a></td>';
+			print "<td class=\"linenr\"><a class=\"linenr\" href=\"\">$linenr</a></td><td class=\"pre\">" . esc_html($_) . "</td>\n";
+			print "</tr>\n";
+			next;
+		}
+
 		my ($full_rev, $orig_lineno, $lineno, $group_size) =
 		    /^([0-9a-f]{40}) (\d+) (\d+)(?: (\d+))?$/;
 		if (!exists $metainfo{$full_rev}) {
@@ -3618,13 +3675,30 @@ HTML
 		print "<td class=\"pre\">" . esc_html($data) . "</td>\n";
 		print "</tr>\n";
 	}
+
 	print "</table>\n";
 	print "</div>";
 	close $fd
 		or print "Reading blob failed\n";
+
+	if ($type eq 'incremental') {
+		print "<script type=\"text/javascript\">\n";
+		print "startBlame(\"" . href(action=>"blame_data", hash_base=>$hash_base, file_name=>$file_name) . "\", \"" .
+		  href(-partial_query=>1) . "\");\n";
+		print "</script>\n";
+	}
+
 	git_footer_html();
 }
 
+sub git_blame_incremental {
+	git_blame_common('incremental');
+}
+
+sub git_blame2 {
+	git_blame_common('oneshot');
+}
+
 sub git_blame {
 	my $fd;
 
-- 
1.5.2.rc3.802.g4b4b7

^ permalink raw reply related

* [PATCH 2/5] gitweb: support filename prefix in git_patchset_body/git_difftree_body
From: Martin Koegler @ 2007-05-20 20:23 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git, Martin Koegler
In-Reply-To: <11796926121641-git-send-email-mkoegler@auto.tuwien.ac.at>

git_treediff supports comparing subdirectories. As the output of
git-difftree is missing the path to the compared directories,
the links in the output would be wrong.

The patch adds two new parameters to add the missing path prefix.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
 gitweb/gitweb.perl |   72 +++++++++++++++++++++++++++++-----------------------
 1 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 63ed14f..33aba86 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2366,9 +2366,13 @@ sub from_ids_eq {
 
 
 sub git_difftree_body {
-	my ($difftree, $hash, @parents) = @_;
+	my ($difftree, $from_prefix, $to_prefix, $hash, @parents) = @_;
 	my ($parent) = $parents[0];
 	my ($have_blame) = gitweb_check_feature('blame');
+
+	$from_prefix = !defined $from_prefix ? '' : $from_prefix.'/';
+	$to_prefix   = !defined $to_prefix   ? '' : $to_prefix . '/';
+
 	print "<div class=\"list_head\">\n";
 	if ($#{$difftree} > 10) {
 		print(($#{$difftree} + 1) . " files changed:\n");
@@ -2405,7 +2409,7 @@ sub git_difftree_body {
 				# file exists in the result (child) commit
 				print "<td>" .
 				      $cgi->a({-href => href(action=>"blob", hash=>$diff->{'to_id'},
-				                             file_name=>$diff->{'to_file'},
+				                             file_name=>$to_prefix.$diff->{'to_file'},
 				                             hash_base=>$hash),
 				              -class => "list"}, esc_path($diff->{'to_file'})) .
 				      "</td>\n";
@@ -2442,7 +2446,7 @@ sub git_difftree_body {
 					      $cgi->a({-href => href(action=>"blob",
 					                             hash_base=>$hash,
 					                             hash=>$from_hash,
-					                             file_name=>$from_path)},
+					                             file_name=>$from_prefix.$from_path)},
 					              "blob" . ($i+1)) .
 					      " | </td>\n";
 				} else {
@@ -2456,8 +2460,8 @@ sub git_difftree_body {
 					                             hash_parent=>$from_hash,
 					                             hash_base=>$hash,
 					                             hash_parent_base=>$hash_parent,
-					                             file_name=>$diff->{'to_file'},
-					                             file_parent=>$from_path)},
+					                             file_name=>$to_prefix.$diff->{'to_file'},
+					                             file_parent=>$from_prefix.$from_path)},
 					              "diff" . ($i+1)) .
 					      " | </td>\n";
 				}
@@ -2467,14 +2471,14 @@ sub git_difftree_body {
 			if ($not_deleted) {
 				print $cgi->a({-href => href(action=>"blob",
 				                             hash=>$diff->{'to_id'},
-				                             file_name=>$diff->{'to_file'},
+				                             file_name=>$to_prefix.$diff->{'to_file'},
 				                             hash_base=>$hash)},
 				              "blob");
 				print " | " if ($has_history);
 			}
 			if ($has_history) {
 				print $cgi->a({-href => href(action=>"history",
-				                             file_name=>$diff->{'to_file'},
+				                             file_name=>$to_prefix.$diff->{'to_file'},
 				                             hash_base=>$hash)},
 				              "history");
 			}
@@ -2508,7 +2512,7 @@ sub git_difftree_body {
 			$mode_chng   .= "]</span>";
 			print "<td>";
 			print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'to_id'},
-			                             hash_base=>$hash, file_name=>$diff->{'file'}),
+			                             hash_base=>$hash, file_name=>$to_prefix.$diff->{'file'}),
 			              -class => "list"}, esc_path($diff->{'file'}));
 			print "</td>\n";
 			print "<td>$mode_chng</td>\n";
@@ -2520,7 +2524,7 @@ sub git_difftree_body {
 				print " | ";
 			}
 			print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'to_id'},
-			                             hash_base=>$hash, file_name=>$diff->{'file'})},
+			                             hash_base=>$hash, file_name=>$to_prefix.$diff->{'file'})},
 			              "blob");
 			print "</td>\n";
 
@@ -2528,7 +2532,7 @@ sub git_difftree_body {
 			my $mode_chng = "<span class=\"file_status deleted\">[deleted $from_file_type]</span>";
 			print "<td>";
 			print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'from_id'},
-			                             hash_base=>$parent, file_name=>$diff->{'file'}),
+			                             hash_base=>$parent, file_name=>$from_prefix.$diff->{'file'}),
 			               -class => "list"}, esc_path($diff->{'file'}));
 			print "</td>\n";
 			print "<td>$mode_chng</td>\n";
@@ -2540,15 +2544,15 @@ sub git_difftree_body {
 				print " | ";
 			}
 			print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'from_id'},
-			                             hash_base=>$parent, file_name=>$diff->{'file'})},
+			                             hash_base=>$parent, file_name=>$from_prefix.$diff->{'file'})},
 			              "blob") . " | ";
 			if ($have_blame) {
 				print $cgi->a({-href => href(action=>"blame", hash_base=>$parent,
-				                             file_name=>$diff->{'file'})},
+				                             file_name=>$from_prefix.$diff->{'file'})},
 				              "blame") . " | ";
 			}
 			print $cgi->a({-href => href(action=>"history", hash_base=>$parent,
-			                             file_name=>$diff->{'file'})},
+			                             file_name=>$from_prefix.$diff->{'file'})},
 			              "history");
 			print "</td>\n";
 
@@ -2570,7 +2574,7 @@ sub git_difftree_body {
 			}
 			print "<td>";
 			print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'to_id'},
-			                             hash_base=>$hash, file_name=>$diff->{'file'}),
+			                             hash_base=>$hash, file_name=>$to_prefix.$diff->{'file'}),
 			              -class => "list"}, esc_path($diff->{'file'}));
 			print "</td>\n";
 			print "<td>$mode_chnge</td>\n";
@@ -2585,20 +2589,21 @@ sub git_difftree_body {
 				print $cgi->a({-href => href(action=>"blobdiff",
 				                             hash=>$diff->{'to_id'}, hash_parent=>$diff->{'from_id'},
 				                             hash_base=>$hash, hash_parent_base=>$parent,
-				                             file_name=>$diff->{'file'})},
+				                             file_name=>$to_prefix.$diff->{'file'},
+				                             file_parent=>$from_prefix.$diff->{'file'})},
 				              "diff") .
 				      " | ";
 			}
 			print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'to_id'},
-			                             hash_base=>$hash, file_name=>$diff->{'file'})},
+			                             hash_base=>$hash, file_name=>$to_prefix.$diff->{'file'})},
 			               "blob") . " | ";
 			if ($have_blame) {
 				print $cgi->a({-href => href(action=>"blame", hash_base=>$hash,
-				                             file_name=>$diff->{'file'})},
+				                             file_name=>$to_prefix.$diff->{'file'})},
 				              "blame") . " | ";
 			}
 			print $cgi->a({-href => href(action=>"history", hash_base=>$hash,
-			                             file_name=>$diff->{'file'})},
+			                             file_name=>$to_prefix.$diff->{'file'})},
 			              "history");
 			print "</td>\n";
 
@@ -2612,11 +2617,11 @@ sub git_difftree_body {
 			}
 			print "<td>" .
 			      $cgi->a({-href => href(action=>"blob", hash_base=>$hash,
-			                             hash=>$diff->{'to_id'}, file_name=>$diff->{'to_file'}),
+			                             hash=>$diff->{'to_id'}, file_name=>$to_prefix.$diff->{'to_file'}),
 			              -class => "list"}, esc_path($diff->{'to_file'})) . "</td>\n" .
 			      "<td><span class=\"file_status $nstatus\">[$nstatus from " .
 			      $cgi->a({-href => href(action=>"blob", hash_base=>$parent,
-			                             hash=>$diff->{'from_id'}, file_name=>$diff->{'from_file'}),
+			                             hash=>$diff->{'from_id'}, file_name=>$from_prefix.$diff->{'from_file'}),
 			              -class => "list"}, esc_path($diff->{'from_file'})) .
 			      " with " . (int $diff->{'similarity'}) . "% similarity$mode_chng]</span></td>\n" .
 			      "<td class=\"link\">";
@@ -2630,20 +2635,20 @@ sub git_difftree_body {
 				print $cgi->a({-href => href(action=>"blobdiff",
 				                             hash=>$diff->{'to_id'}, hash_parent=>$diff->{'from_id'},
 				                             hash_base=>$hash, hash_parent_base=>$parent,
-				                             file_name=>$diff->{'to_file'}, file_parent=>$diff->{'from_file'})},
+				                             file_name=>$to_prefix.$diff->{'to_file'}, file_parent=>$from_prefix.$diff->{'from_file'})},
 				              "diff") .
 				      " | ";
 			}
 			print $cgi->a({-href => href(action=>"blob", hash=>$diff->{'to_id'},
-			                             hash_base=>$parent, file_name=>$diff->{'to_file'})},
+			                             hash_base=>$parent, file_name=>$to_prefix.$diff->{'to_file'})},
 			              "blob") . " | ";
 			if ($have_blame) {
 				print $cgi->a({-href => href(action=>"blame", hash_base=>$hash,
-				                             file_name=>$diff->{'to_file'})},
+				                             file_name=>$to_prefix.$diff->{'to_file'})},
 				              "blame") . " | ";
 			}
 			print $cgi->a({-href => href(action=>"history", hash_base=>$hash,
-			                            file_name=>$diff->{'to_file'})},
+			                            file_name=>$to_prefix.$diff->{'to_file'})},
 			              "history");
 			print "</td>\n";
 
@@ -2654,7 +2659,7 @@ sub git_difftree_body {
 }
 
 sub git_patchset_body {
-	my ($fd, $difftree, $hash, @hash_parents) = @_;
+	my ($fd, $difftree, $from_prefix, $to_prefix, $hash, @hash_parents) = @_;
 	my ($hash_parent) = $hash_parents[0];
 
 	my $patch_idx = 0;
@@ -2663,6 +2668,9 @@ sub git_patchset_body {
 	my $diffinfo;
 	my (%from, %to);
 
+	$from_prefix = !defined $from_prefix ? '' : $from_prefix.'/';
+	$to_prefix   = !defined $to_prefix   ? '' : $to_prefix . '/';
+
 	print "<div class=\"patchset\">\n";
 
 	# skip to first patch
@@ -2733,7 +2741,7 @@ sub git_patchset_body {
 						$from{'href'}[$i] = href(action=>"blob",
 						                         hash_base=>$hash_parents[$i],
 						                         hash=>$diffinfo->{'from_id'}[$i],
-						                         file_name=>$from{'file'}[$i]);
+						                         file_name=>$from_prefix.$from{'file'}[$i]);
 					} else {
 						$from{'href'}[$i] = undef;
 					}
@@ -2743,7 +2751,7 @@ sub git_patchset_body {
 				if ($diffinfo->{'status'} ne "A") { # not new (added) file
 					$from{'href'} = href(action=>"blob", hash_base=>$hash_parent,
 					                     hash=>$diffinfo->{'from_id'},
-					                     file_name=>$from{'file'});
+					                     file_name=>$from_prefix.$from{'file'});
 				} else {
 					delete $from{'href'};
 				}
@@ -2753,7 +2761,7 @@ sub git_patchset_body {
 			if ($diffinfo->{'to_id'} ne ('0' x 40)) { # file exists in result
 				$to{'href'} = href(action=>"blob", hash_base=>$hash,
 				                   hash=>$diffinfo->{'to_id'},
-				                   file_name=>$to{'file'});
+				                   file_name=>$to_prefix.$to{'file'});
 			} else {
 				delete $to{'href'};
 			}
@@ -4180,7 +4188,7 @@ sub git_commit {
 	git_print_log($co{'comment'});
 	print "</div>\n";
 
-	git_difftree_body(\@difftree, $hash, @$parents);
+	git_difftree_body(\@difftree, undef, undef, $hash, @$parents);
 
 	git_footer_html();
 }
@@ -4338,7 +4346,7 @@ sub git_blobdiff {
 	if ($format eq 'html') {
 		print "<div class=\"page_body\">\n";
 
-		git_patchset_body($fd, [ \%diffinfo ], $hash_base, $hash_parent_base);
+		git_patchset_body($fd, [ \%diffinfo ], undef, undef, $hash_base, $hash_parent_base);
 		close $fd;
 
 		print "</div>\n"; # class="page_body"
@@ -4495,10 +4503,10 @@ TEXT
 
 	# write patch
 	if ($format eq 'html') {
-		git_difftree_body(\@difftree, $hash, $hash_parent || @{$co{'parents'}});
+		git_difftree_body(\@difftree, undef, undef, $hash, $hash_parent || @{$co{'parents'}});
 		print "<br/>\n";
 
-		git_patchset_body($fd, \@difftree, $hash, $hash_parent || @{$co{'parents'}});
+		git_patchset_body($fd, \@difftree, undef, undef, $hash, $hash_parent || @{$co{'parents'}});
 		close $fd;
 		print "</div>\n"; # class="page_body"
 		git_footer_html();
-- 
1.5.2.rc3.802.g4b4b7

^ permalink raw reply related

* [PATCH 4/5] gitweb: Selecting diffs in JavaScript
From: Martin Koegler @ 2007-05-20 20:23 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git, Martin Koegler
In-Reply-To: <11796926121911-git-send-email-mkoegler@auto.tuwien.ac.at>

The adds support for selecting arbitrary diffs, if the client browser supports
JavaScript.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
 Makefile           |    6 +-
 git-instaweb.sh    |    7 ++
 gitweb/gitweb.js   |  298 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gitweb/gitweb.perl |    6 +
 4 files changed, 316 insertions(+), 1 deletions(-)
 create mode 100644 gitweb/gitweb.js

diff --git a/Makefile b/Makefile
index 521c003..2d04ef9 100644
--- a/Makefile
+++ b/Makefile
@@ -167,6 +167,7 @@ GITWEB_HOMETEXT = indextext.html
 GITWEB_CSS = gitweb.css
 GITWEB_LOGO = git-logo.png
 GITWEB_FAVICON = git-favicon.png
+GITWEB_JS = gitweb.js
 GITWEB_SITE_HEADER =
 GITWEB_SITE_FOOTER =
 
@@ -811,13 +812,14 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
 	    -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
 	    -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
 	    -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
+	    -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
 	    -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
 	    -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
 	    $< >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
 
-git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
+git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js
 	$(QUIET_GEN)rm -f $@ $@+ && \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
@@ -826,6 +828,8 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
 	    -e '/@@GITWEB_CGI@@/d' \
 	    -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
 	    -e '/@@GITWEB_CSS@@/d' \
+	    -e '/@@GITWEB_JS@@/r gitweb/gitweb.js' \
+	    -e '/@@GITWEB_JS@@/d' \
 	    $@.sh > $@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
diff --git a/git-instaweb.sh b/git-instaweb.sh
index cbc7418..8cb62f1 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -233,8 +233,15 @@ gitweb_css () {
 EOFGITWEB
 }
 
+gitweb_js () {
+	cat > "$1" <<\EOFGITWEB
+@@GITWEB_JS@@
+EOFGITWEB
+}
+
 gitweb_cgi $GIT_DIR/gitweb/gitweb.cgi
 gitweb_css $GIT_DIR/gitweb/gitweb.css
+gitweb_js $GIT_DIR/gitweb/gitweb.js
 
 case "$httpd" in
 *lighttpd*)
diff --git a/gitweb/gitweb.js b/gitweb/gitweb.js
new file mode 100644
index 0000000..cacab5a
--- /dev/null
+++ b/gitweb/gitweb.js
@@ -0,0 +1,298 @@
+/* Javascript functions for gitweb
+
+  (C) 2007 Martin Koegler <mkoegler@auto.tuwien.ac.at>
+
+  This file is licensed under the GPL v2, or (at your option) any later version.
+*/
+
+function getCookie (name)
+{
+  var name = name + "=";
+  var c = document.cookie;
+  var p = c.indexOf (name);
+  if (p == -1)
+    return null;
+  c = c.substr (p + name.length, c.length);
+  p = c.indexOf (";");
+  if (p == -1)
+    return c;
+  else
+    return c.substr (0, p);
+}
+
+function insertAfter (elem, node)
+{
+  if (node.nextSibling)
+    node.parentNode.insertBefore (elem, node.nextSibling);
+  else
+    node.parentNode.appendChild (elem);
+}
+
+function createLink (href, linktext)
+{
+  var l = document.createElement ("a");
+  l.appendChild (document.createTextNode (linktext));
+  l.href = href;
+  return l;
+}
+
+function createLinkGroup (href1, basetxt, href2, difftxt)
+{
+  var l = document.createElement ("span");
+  l.appendChild (document.createTextNode (" ("));
+  l.appendChild (createLink (href1, basetxt));
+  l.appendChild (document.createTextNode (" | "));
+  l.appendChild (createLink (href2, difftxt));
+  l.appendChild (document.createTextNode (") "));
+  return l;
+}
+
+function GitRef ()
+{
+  this.t = null;
+  this.h = null;
+  this.hb = null;
+  this.f = null;
+  this.p = null;
+  this.ToRef = ToRef;
+}
+
+function ToRef ()
+{
+  var parts = new Array ();
+  if (this.f)
+    parts.push ("f=" + this.f);
+  if (this.h)
+    parts.push ("h=" + this.h);
+  if (this.hb)
+    parts.push ("hb=" + this.hb);
+  if (this.t)
+    parts.push ("t=" + this.t);
+  if (this.p)
+    parts.push ("p=" + this.p);
+  return parts.join ("@");
+}
+
+function splitGitRef (ref)
+{
+  var parts = ref.split ("@");
+  var res = new GitRef ();
+  var i;
+  for (i = 0; i < parts.length; i++)
+    {
+      var p = parts[i].split ("=");
+      res[p[0]] = p[1];
+    }
+  return res;
+}
+
+function GitURL (base)
+{
+  this.base = base;
+  this.p = null;
+  this.a = null;
+  this.f = null;
+  this.fp = null;
+  this.h = null;
+  this.hp = null;
+  this.hb = null;
+  this.hpb = null;
+  this.pg = null;
+  this.o = null;
+  this.s = null;
+  this.st = null;
+  this.ToURL = ToURL;
+  this.ToRef = UrlToRef;
+  this.ToDUrl = ToDUrl;
+}
+
+function ToURL ()
+{
+  var parts = new Array ();
+  if (this.p)
+    parts.push ("p=" + this.p);
+  if (this.a)
+    parts.push ("a=" + this.a);
+  if (this.f)
+    parts.push ("f=" + this.f);
+  if (this.fp)
+    parts.push ("fp=" + this.fp);
+  if (this.h)
+    parts.push ("h=" + this.h);
+  if (this.hp)
+    parts.push ("hp=" + this.hp);
+  if (this.hb)
+    parts.push ("hb=" + this.hb);
+  if (this.hpb)
+    parts.push ("hpb=" + this.hpb);
+  if (this.o)
+    parts.push ("o=" + this.o);
+  if (this.s)
+    parts.push ("s=" + this.s);
+  if (this.st)
+    parts.push ("st=" + this.st);
+  return this.base + "?" + parts.join (";");
+}
+
+function UrlToRef (type)
+{
+  var res = new GitRef;
+  res.f = this.f;
+  res.h = this.h;
+  res.hb = this.hb;
+  res.t = type;
+  res.p = this.p;
+  return res.ToRef ();
+}
+
+function ToDUrl (type)
+{
+  var res = new GitURL (this.base);
+  res.f = this.f;
+  res.h = this.h;
+  res.hb = this.hb;
+  res.p = this.p;
+  res.a = type;
+  return res.ToURL ();
+}
+
+function splitGitURL (url)
+{
+  var Urls = url.split ("?");
+  var res = new GitURL (Urls[0]);
+  if (Urls.length > 1)
+    {
+      var parts = Urls[1].split (";");
+      var i;
+      for (i = 0; i < parts.length; i++)
+	{
+	  var p = parts[i].split ("=");
+	  res[p[0]] = p[1];
+	}
+    }
+  return res;
+}
+
+function base (ref)
+{
+  document.cookie = "basename=" + ref;
+}
+
+function diff (url)
+{
+  var c = getCookie ("basename");
+  if (!c)
+    {
+      alert ("no diff base selected");
+      return;
+    }
+  c = splitGitRef (c);
+  url = splitGitURL (url);
+
+  if (c.p != url.p)
+    {
+      alert ("base object in an other repository");
+      return;
+    }
+
+  if (c.t == 'commit' && url.a == 'commit')
+    {
+      url.a = 'commitdiff';
+      if (!c.h || !url.h)
+	{
+	  alert ("commit diff not possible");
+	  return;
+	}
+      url.hb = null;
+      url.f = null;
+      url.hp = c.h;
+      document.location.href = url.ToURL ();
+      return;
+    }
+  if (c.t == 'blob' && url.a == 'blob')
+    {
+      url.a = 'blobdiff';
+      url.hp = c.h;
+      url.hpb = c.hb;
+      url.fp = c.f;
+      document.location.href = url.ToURL ();
+      return;
+    }
+  if (c.t == 'tree' && url.a == 'tree')
+    {
+      url.a = 'treediff';
+      url.hpb = c.hb;
+      url.hp = c.h;
+      url.fp = c.f;
+      document.location.href = url.ToURL ();
+      return;
+    }
+  if (c.t == 'commit' && url.a == 'tree')
+    {
+      url.a = 'treediff';
+      url.hpb = c.h;
+      url.hp = null;
+      url.fp = null;
+      document.location.href = url.ToURL ();
+      return;
+    }
+  if (c.t == 'tree' && url.a == 'commit')
+    {
+      url.a = 'treediff';
+      url.hpb = c.hb;
+      url.hp = c.h;
+      url.fp = c.f;
+      url.hb = url.h;
+      url.h = null;
+      document.location.href = url.ToURL ();
+      return;
+    }
+  alert ("diff not possible");
+}
+
+function GitAddLinks ()
+{
+  var links = document.getElementsByTagName ("a");
+  var i;
+
+  for (i = 0; i < links.length; i++)
+    {
+      var link = links[i];
+      var url = splitGitURL (link.href);
+      if (link.innerHTML == 'commit' || link.innerHTML == 'tag')
+	{
+	  if (!url.h)
+	    continue;
+	  var l =
+	    createLinkGroup ("javascript:base('" + url.ToRef ('commit') +
+			     "')", "base",
+			     "javascript:diff('" + url.ToDUrl ('commit') +
+			     "')", "diff");
+	  insertAfter (l, link);
+	}
+      if (link.innerHTML == 'blob')
+	{
+	  if (!url.h && !(url.hb && url.f))
+	    continue;
+	  var l =
+	    createLinkGroup ("javascript:base('" + url.ToRef ('blob') + "')",
+			     "base",
+			     "javascript:diff('" + url.ToDUrl ('blob') + "')",
+			     "diff");
+	  insertAfter (l, link);
+	}
+      if (link.innerHTML == 'tree')
+	{
+	  if (!url.h && !(url.hb && url.f))
+	    continue;
+	  var l =
+	    createLinkGroup ("javascript:base('" + url.ToRef ('tree') + "')",
+			     "base",
+			     "javascript:diff('" + url.ToDUrl ('tree') + "')",
+			     "diff");
+	  insertAfter (l, link);
+	}
+    }
+}
+
+window.onload = GitAddLinks;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d161c8b..f59a4b5 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -61,6 +61,8 @@ our $stylesheet = undef;
 our $logo = "++GITWEB_LOGO++";
 # URI of GIT favicon, assumed to be image/png type
 our $favicon = "++GITWEB_FAVICON++";
+# URI of gitweb.js
+our $gitwebjs = "++GITWEB_JS++";
 
 # URI and label (title) of GIT logo link
 #our $logo_url = "http://www.kernel.org/pub/software/scm/git/docs/";
@@ -1909,6 +1911,10 @@ EOF
 		print qq(<link rel="shortcut icon" href="$favicon" type="image/png"/>\n);
 	}
 
+	if (defined $gitwebjs) {
+		print qq(<script src="$gitwebjs" type="text/javascript"></script>\n);
+	}
+
 	print "</head>\n" .
 	      "<body>\n";
 
-- 
1.5.2.rc3.802.g4b4b7

^ permalink raw reply related

* [PATCH 1/5] gitweb: Support comparing blobs with different names
From: Martin Koegler @ 2007-05-20 20:23 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git, Martin Koegler

Currently, blobdiff can only compare blobs with different file
names, if no hb/hpb parameters are present.

This patch adds support for comparing two blobs specified by any
combination of hb/f/h and hpb/fp/hp.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
 gitweb/gitweb.perl |  148 +++++++++++++++++++---------------------------------
 1 files changed, 53 insertions(+), 95 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 5c7011a..63ed14f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4238,109 +4238,66 @@ sub git_blobdiff {
 	my $fd;
 	my @difftree;
 	my %diffinfo;
-	my $expires;
-
-	# preparing $fd and %diffinfo for git_patchset_body
-	# new style URI
-	if (defined $hash_base && defined $hash_parent_base) {
-		if (defined $file_name) {
-			# read raw output
-			open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
-				$hash_parent_base, $hash_base,
-				"--", (defined $file_parent ? $file_parent : ()), $file_name
-				or die_error(undef, "Open git-diff-tree failed");
-			@difftree = map { chomp; $_ } <$fd>;
-			close $fd
-				or die_error(undef, "Reading git-diff-tree failed");
-			@difftree
-				or die_error('404 Not Found', "Blob diff not found");
-
-		} elsif (defined $hash &&
-		         $hash =~ /[0-9a-fA-F]{40}/) {
-			# try to find filename from $hash
-
-			# read filtered raw output
-			open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
-				$hash_parent_base, $hash_base, "--"
-				or die_error(undef, "Open git-diff-tree failed");
-			@difftree =
-				# ':100644 100644 03b21826... 3b93d5e7... M	ls-files.c'
-				# $hash == to_id
-				grep { /^:[0-7]{6} [0-7]{6} [0-9a-fA-F]{40} $hash/ }
-				map { chomp; $_ } <$fd>;
-			close $fd
-				or die_error(undef, "Reading git-diff-tree failed");
-			@difftree
-				or die_error('404 Not Found', "Blob diff not found");
+	my $expires = '+1d';
+	my ($from, $to);
 
-		} else {
-			die_error('404 Not Found', "Missing one of the blob diff parameters");
-		}
-
-		if (@difftree > 1) {
-			die_error('404 Not Found', "Ambiguous blob diff specification");
-		}
+	$file_parent ||= $file_name;
 
-		%diffinfo = parse_difftree_raw_line($difftree[0]);
-		$file_parent ||= $diffinfo{'from_file'} || $file_name || $diffinfo{'file'};
-		$file_name   ||= $diffinfo{'to_file'}   || $diffinfo{'file'};
-
-		$hash_parent ||= $diffinfo{'from_id'};
-		$hash        ||= $diffinfo{'to_id'};
-
-		# non-textual hash id's can be cached
-		if ($hash_base =~ m/^[0-9a-fA-F]{40}$/ &&
-		    $hash_parent_base =~ m/^[0-9a-fA-F]{40}$/) {
-			$expires = '+1d';
-		}
+	# non-textual hash id's can be cached
+	if (defined $hash && $hash !~ m/^[0-9a-fA-F]{40}$/) {
+		$expires = undef;
+	} elsif (defined $hash_parent && $hash_parent !~ m/^[0-9a-fA-F]{40}$/) {
+		$expires = undef;
+	} elsif (defined $hash_base && $hash_base !~ m/^[0-9a-fA-F]{40}$/) {
+		$expires = undef;
+	} elsif (defined $hash_parent_base && $hash_parent_base !~ m/^[0-9a-fA-F]{40}$/) {
+		$expires = undef;
+	}
+
+	# if hash parameter is missing, read it from the commit.
+	if (defined $hash_base && defined $file_name && !defined $hash) {
+		$hash = git_get_hash_by_path($hash_base, $file_name);
+	}
 
-		# open patch output
-		open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
-			'-p', ($format eq 'html' ? "--full-index" : ()),
-			$hash_parent_base, $hash_base,
-			"--", (defined $file_parent ? $file_parent : ()), $file_name
-			or die_error(undef, "Open git-diff-tree failed");
+	if (defined $hash_parent_base && defined $file_parent && !defined $hash_parent) {
+	    $hash_parent = git_get_hash_by_path($hash_parent_base, $file_parent);
+	}
+	
+	if (!defined $hash || ! defined $hash_parent) {
+		die_error('404 Not Found', "Missing one of the blob diff parameters");
 	}
 
-	# old/legacy style URI
-	if (!%diffinfo && # if new style URI failed
-	    defined $hash && defined $hash_parent) {
-		# fake git-diff-tree raw output
-		$diffinfo{'from_mode'} = $diffinfo{'to_mode'} = "blob";
-		$diffinfo{'from_id'} = $hash_parent;
-		$diffinfo{'to_id'}   = $hash;
-		if (defined $file_name) {
-			if (defined $file_parent) {
-				$diffinfo{'status'} = '2';
-				$diffinfo{'from_file'} = $file_parent;
-				$diffinfo{'to_file'}   = $file_name;
-			} else { # assume not renamed
-				$diffinfo{'status'} = '1';
-				$diffinfo{'from_file'} = $file_name;
-				$diffinfo{'to_file'}   = $file_name;
-			}
-		} else { # no filename given
-			$diffinfo{'status'} = '2';
-			$diffinfo{'from_file'} = $hash_parent;
-			$diffinfo{'to_file'}   = $hash;
-		}
+	if (defined $hash_base && defined $file_name) {
+		$to = $hash_base . ':' . $file_name;
+	} else {
+		$to = $hash;
+	}
 
-		# non-textual hash id's can be cached
-		if ($hash =~ m/^[0-9a-fA-F]{40}$/ &&
-		    $hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
-			$expires = '+1d';
-		}
+	if (defined $hash_parent_base && defined $file_parent) {
+		$from = $hash_parent_base . ':' . $file_parent;
+	} else {
+		$from = $hash_parent;
+	}
 
-		# open patch output
-		open $fd, "-|", git_cmd(), "diff", @diff_opts,
-			'-p', ($format eq 'html' ? "--full-index" : ()),
-			$hash_parent, $hash, "--"
-			or die_error(undef, "Open git-diff failed");
-	} else  {
-		die_error('404 Not Found', "Missing one of the blob diff parameters")
-			unless %diffinfo;
+	# fake git-diff-tree raw output
+	$diffinfo{'from_mode'} = $diffinfo{'to_mode'} = "blob";
+	$diffinfo{'from_id'} = $hash_parent;
+	$diffinfo{'to_id'}   = $hash;
+	if (defined $file_name) {
+		$diffinfo{'status'} = '2';
+		$diffinfo{'from_file'} = $file_parent;
+		$diffinfo{'to_file'}   = $file_name;
+	} else { # no filename given
+		$diffinfo{'status'} = '2';
+		$diffinfo{'from_file'} = $hash_parent;
+		$diffinfo{'to_file'}   = $hash;
 	}
 
+	# open patch output
+	open $fd, "-|", git_cmd(), "diff", @diff_opts, '-p', "--full-index",
+	($format eq 'html' ? "--raw" : ()), $from, $to, "--"
+		or die_error(undef, "Open git-diff failed");
+
 	# header
 	if ($format eq 'html') {
 		my $formats_nav =
@@ -4364,11 +4321,12 @@ sub git_blobdiff {
 		}
 
 	} elsif ($format eq 'plain') {
+		my $patch_file_name = $file_name || $hash;
 		print $cgi->header(
 			-type => 'text/plain',
 			-charset => 'utf-8',
 			-expires => $expires,
-			-content_disposition => 'inline; filename="' . "$file_name" . '.patch"');
+			-content_disposition => 'inline; filename="' . "$patch_file_name" . '.patch"');
 
 		print "X-Git-Url: " . $cgi->self_url() . "\n\n";
 
-- 
1.5.2.rc3.802.g4b4b7

^ permalink raw reply related

* [PATCH 3/5] gitweb: Add treediff view
From: Martin Koegler @ 2007-05-20 20:23 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git, Martin Koegler
In-Reply-To: <11796926121315-git-send-email-mkoegler@auto.tuwien.ac.at>

git_treediff supports comparing different trees. A tree can be specified
either as hash or as base hash and filename.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
 gitweb/gitweb.perl |  116 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 33aba86..d161c8b 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -480,6 +480,8 @@ my %actions = (
 	"tag" => \&git_tag,
 	"tags" => \&git_tags,
 	"tree" => \&git_tree,
+	"treediff" => \&git_treediff,
+	"treediff_plain" => \&git_treediff_plain,
 	"snapshot" => \&git_snapshot,
 	"object" => \&git_object,
 	# those below don't need $project
@@ -4523,6 +4525,120 @@ sub git_commitdiff_plain {
 	git_commitdiff('plain');
 }
 
+sub git_treediff {
+	my $format = shift || 'html';
+	my $expires = '+1d';
+
+	# non-textual hash id's can be cached
+	if (defined $hash && $hash !~ m/^[0-9a-fA-F]{40}$/) {
+		$expires = undef;
+	} elsif (defined $hash_parent && $hash_parent !~ m/^[0-9a-fA-F]{40}$/) {
+		$expires = undef;
+	} elsif (defined $hash_base && $hash_base !~ m/^[0-9a-fA-F]{40}$/) {
+		$expires = undef;
+	} elsif (defined $hash_parent_base && $hash_parent_base !~ m/^[0-9a-fA-F]{40}$/) {
+		$expires = undef;
+	}
+
+	# we need to prepare $formats_nav before any parameter munging
+	my $formats_nav;
+	if ($format eq 'html') {
+		$formats_nav =
+			$cgi->a({-href => href(action=>"treediff_plain",
+								   hash=>$hash, hash_parent=>$hash_parent,
+								   hash_base=>$hash_base, hash_parent_base=>$hash_parent_base,
+								   file_name=>$file_name, file_parent=>$file_parent)},
+					"raw");
+	}
+
+	if (!defined $hash) {
+		if (!defined $hash_base) {
+			die_error(undef,'tree parameter missing');
+		}
+		$hash = $hash_base;
+		$hash .= ":".$file_name if (defined $file_name);
+	}
+	
+	if (!defined $hash_parent) {
+		if (!defined $hash_parent_base) {
+			die_error(undef,'tree parameter missing');
+		}
+		$hash_parent = $hash_parent_base;
+		$hash_parent .= ":".$file_parent if (defined $file_parent);
+	}
+
+	# read treediff
+	my $fd;
+	my @difftree;
+	if ($format eq 'html') {
+		open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
+		"--no-commit-id", "--patch-with-raw", "--full-index",
+		$hash_parent, $hash, "--"
+			or die_error(undef, "Open git-diff-tree failed");
+		
+		while (my $line = <$fd>) {
+			chomp $line;
+			# empty line ends raw part of diff-tree output
+			last unless $line;
+			push @difftree, $line;
+		}
+		
+	} elsif ($format eq 'plain') {
+		open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
+		'-p', $hash_parent, $hash, "--"
+			or die_error(undef, "Open git-diff-tree failed");
+		
+	} else {
+		die_error(undef, "Unknown treediff format");
+	}
+
+	# write header
+	if ($format eq 'html') {
+		git_header_html(undef, $expires);
+		if (defined $hash_base && (my %co = parse_commit($hash_base))) {
+			git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
+			git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
+		} else {
+			print "<div class=\"page_nav\"><br/>$formats_nav<br/></div>\n";
+			print "<div class=\"title\">$hash vs $hash_parent</div>\n";
+		}
+		print "<div class=\"page_body\">\n";
+		
+	} elsif ($format eq 'plain') {
+		my $filename = basename($project) . "-$hash-$hash_parent.patch";
+		
+		print $cgi->header(
+						   -type => 'text/plain',
+						   -charset => 'utf-8',
+						   -expires => $expires,
+						   -content_disposition => 'inline; filename="' . "$filename" . '"');
+		
+		print "X-Git-Url: " . $cgi->self_url() . "\n\n";
+		print "---\n\n";
+	}
+	
+	# write patch
+	if ($format eq 'html') {
+		git_difftree_body(\@difftree, $file_parent, $file_name, $hash_base, $hash_parent_base);
+		print "<br/>\n";
+
+		git_patchset_body($fd, \@difftree, $file_parent, $file_name, $hash_base, $hash_parent_base);
+		close $fd;
+		print "</div>\n"; # class="page_body"
+		git_footer_html();
+
+	} elsif ($format eq 'plain') {
+		local $/ = undef;
+		print <$fd>;
+		close $fd
+			or print "Reading git-diff-tree failed\n";
+	}
+}
+
+sub git_treediff_plain {
+	git_treediff('plain');
+}
+
 sub git_history {
 	if (!defined $hash_base) {
 		$hash_base = git_get_head_hash($project);
-- 
1.5.2.rc3.802.g4b4b7

^ permalink raw reply related

* Re: [PATCH 07/16] git-read-tree: take --submodules option
From: Sven Verdoolaege @ 2007-05-20 20:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jan Hudec, Alex Riesen, git
In-Reply-To: <7vbqgfmjki.fsf@assigned-by-dhcp.cox.net>

On Sun, May 20, 2007 at 11:33:17AM -0700, Junio C Hamano wrote:
> Jan Hudec <bulb@ucw.cz> writes:
> >  - If you fetch from more than one location, you want to fetch subproject
> >    from location corresponding to where you fetch superproject from.
> 
> Not at all.  There is no reason to believe that the case that
> superproject and subproject come from related URLs is more
> common.  One of the reasons to do a separated project
> organization is to allow looser bindings of the project from
> project administrative viewpoint. The integrator may not
> necessarily have any control over what the subproject guys do,
> and more importantly, the subproject people do not even care nor
> be aware of the fact that their project is sometimes bound
> inside other peoples' superprojects.  Think of the embedded
> appliance vendor binding the kernel, libc and busybox in their
> superproject that holds them together with the build
> infrastructure. The kernel folks certainly do not particularly
> care about the vendor.

I think what Jan means is that if there are two (or more) copies
of the superproject then it is more likely that the subproject
commit can be found in the subproject repo "pointed to" (e.g.,
through my submodule.*.url) by the superproject repo you fetched from.

skimo

^ permalink raw reply

* [StGit PATCH 2/2] Don't use / as separatar since it is common i branch names
From: Robin Rosenberg @ 2007-05-20 20:04 UTC (permalink / raw)
  To: 20070506150852.8985.98091.stgit; +Cc: git
In-Reply-To: <20070520200113.14633.90705.stgit@lathund.dewire.com>

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 contrib/stgbashprompt.sh |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/stgbashprompt.sh b/contrib/stgbashprompt.sh
index 7c5dc76..732966a 100755
--- a/contrib/stgbashprompt.sh
+++ b/contrib/stgbashprompt.sh
@@ -8,9 +8,9 @@ if [ "$PS1" ]; then
 		git_dir=$(git-rev-parse --git-dir 2> /dev/null) || return
 		ref=$(git-symbolic-ref HEAD 2> /dev/null) || return
 		br=${ref#refs/heads/}
-		top=$(tail -1 $git_dir/patches/$br/applied 2>/dev/null) \
-			&& top="/$top";
-		echo "[$br$top]"
+		top=$(tail -1 $git_dir/patches/$br/applied 2>/dev/null)
+		top=${top:-(none)}
+		echo "[$top@$br]"
 	}
 	PS1='\u@\h:$(__prompt_git)\W\$ '
 fi

^ permalink raw reply related

* [StGit PATCH 1/2] Update the bash prompt from 'applied' instead of the obsolete 'current'
From: Robin Rosenberg @ 2007-05-20 20:04 UTC (permalink / raw)
  To: 20070506150852.8985.98091.stgit; +Cc: git
In-Reply-To: <20070520200113.14633.90705.stgit@lathund.dewire.com>

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---

 contrib/stgbashprompt.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/stgbashprompt.sh b/contrib/stgbashprompt.sh
index 16bb39b..7c5dc76 100755
--- a/contrib/stgbashprompt.sh
+++ b/contrib/stgbashprompt.sh
@@ -8,8 +8,8 @@ if [ "$PS1" ]; then
 		git_dir=$(git-rev-parse --git-dir 2> /dev/null) || return
 		ref=$(git-symbolic-ref HEAD 2> /dev/null) || return
 		br=${ref#refs/heads/}
-		top=$(cat $git_dir/patches/$br/current 2>/dev/null) \
-			&& top="/$top"
+		top=$(tail -1 $git_dir/patches/$br/applied 2>/dev/null) \
+			&& top="/$top";
 		echo "[$br$top]"
 	}
 	PS1='\u@\h:$(__prompt_git)\W\$ '

^ permalink raw reply related

* [StGit PATCH 0/2] Bash prompt updates
From: Robin Rosenberg @ 2007-05-20 20:03 UTC (permalink / raw)
  To: 20070506150852.8985.98091.stgit; +Cc: git
In-Reply-To: <20070506150852.8985.98091.stgit@yoghurt>

Here is a fix to update the bash prompt so it does not
use the obsolete current file anymore.

Part 2 is my version which uses a different format, mostly
because '/' can be part of the branch name.

-- robin

^ permalink raw reply

* Re: [RFC] Third round of support for cloning submodules
From: Sven Verdoolaege @ 2007-05-20 19:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vhcq7l3ar.fsf@assigned-by-dhcp.cox.net>

On Sun, May 20, 2007 at 12:10:04PM -0700, Junio C Hamano wrote:
> > bash-3.00$ ./git-config --remote=http://www.liacs.nl/~sverdool/isa.git --get-regexp 'submodule\..*\.url' 
> > submodule.cloog.url /home/sverdool/public_html/cloog.git
> > submodule.cloog.url http://www.liacs.nl/~sverdool/cloog.git
> 
> You are priming the process by having these configuration
> variables in the superproject to be cloned (i.e. this is done by
> the owner of the superproject).

Is that a question?
The answer would be that if the user didn't put this information
in a config file, then git will try to get the information from
any remote it can get its hands on.

> What's the design like to make clone and checkout work together?
> When you run the first clone with -n ("do not checkout"), what
> should happen (I am not asking what your code does, but what the
> desired behaviour should be)?  My take on that question is
> "subproject cloning is done by checkout, not clone".

Then I guess you are not asking me.
I took the suggestion of doing the subproject cloning during checkout
from you.

> I am very worried about this big red switch that says "all
> subprojects to be cloned and checked out, or nothing".  I think
> this would not work well with projects that truly need
> superproject support (i.e. very large ones, where most people
> would not want to clone and check out every single subproject).

It's pretty easy to add a "submodule.*.skip" or "submodule.*.ignore".
Since the subcloning only happens at checkout, you could set these
before doing a checkout.

> > I currently do not fetch after the initial clone, since
> > I'm not sure what ref to use for the revision I need to
> > fetch for the supermodule.
> 
> I think fetching inside the subproject can be safely done with
> the default (i.e. refs/heads/*:refs/remotes/origin/*) of 1.5.0
> or later, as long as we tell the users of the feature that they
> should make sure that the commit referenced by superproject tree
> entries are available with such a fetch, which is a sane thing
> to require anyway.

Seems like a pretty strict requirement, but it's easy to implement,
so I guess I can do that in the fourth version.

> The more important issue I think is at what point in the
> superproject operation does a recursive checkout in a subproject
> should happen, and how we should do the checkout.  Issues I can
> think of offhand are (no way exhaustive):
> 
>  - Do we checkout a branch? if so which one?
> 
>  - Do we detach HEAD if the commit named by the superproject
>    tree is not at the tip of the current branch of subproject?
>    do we detach always even if the commit is at the tip?

I thought there was a consensus to detach the HEAD.
I don't have a strong opinion on this issue, but a detached
HEAD seems the most appropriate to me.

>  - What would we do when the subproject working tree is not
>    clean?

I was planning on adding a --dry-run to git-checkout.
The superproject would run this in each subproject before
doing the actual checkout of the superproject.

>  - How can a user decide which subproject to descend into and
>    which subproject to ignore, and how does git remember the
>    earlier decision made by the user without asking the same
>    again, and how does a user express "now I want to also track
>    that subproject I've ignored so far" and "now I am not
>    interested in following that subproject anymore"?

Just twiddle the "submodule.*.skip" option.

> So I tend to disagree with not having the indirection we
> discussed on the other thread about .gitmodules, but I consider
> it a minor detail of cloning, and it is not a major deal to me.

Some form of indirection is definitely required (although
not for my use of submodules) and I'll probably add it in a future round.

skimo

^ permalink raw reply

* Re: [PATCH 02/15] git-config: add --remote option for reading config from remote repo
From: Sven Verdoolaege @ 2007-05-20 19:44 UTC (permalink / raw)
  To: Frank Lichtenheld; +Cc: git, Junio C Hamano
In-Reply-To: <20070520181155.GH4085@planck.djpig.de>

On Sun, May 20, 2007 at 08:11:55PM +0200, Frank Lichtenheld wrote:
> On Sun, May 20, 2007 at 08:04:35PM +0200, skimo@liacs.nl wrote:
> > From: Sven Verdoolaege <skimo@kotnet.org>
> > 
> > Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
> > ---
> >  Documentation/git-config.txt |   33 +++++++++++++++++++++---------
> 
> All my old suggestions and corrections for the documentation
> part still apply... should I repeat them?

I did the [scope] thing, but it seems I inadvertedly threw it out.
I guess I'll have to do it again.

Was there anything else?

skimo

^ permalink raw reply

* git log -S problem
From: Johannes Sixt @ 2007-05-20 19:15 UTC (permalink / raw)
  To: git

There is something odd with -S of git log. Try this in your git.git:

$ git log --pretty=oneline -Sbuiltin-merge-base -- Makefile 
71dfbf224ff980f4085f75868dc409118418731e Make merge-base a built-in.

$ git log --pretty=oneline -Smerge-base -- Makefile
e468305a954d95a26bfcdec3bc6e4bd477d95676 [PATCH] Remove the explicit ...
a3df180138b85a603656582bde6df757095618cf Rename git core commands ...
cef661fc799a3a13ffdea4a3f69f1acd295de53d Add support for alternate ...
e590d694ead8d50c2afc7086161d4ddc5d907655 Add more header dependencies.
6683463ed6b2da9eed309c305806f9393d1ae728 Do a very simple "merge-base"...

$ git version
git version 1.5.2

I had expected that the set of commits found by the second search string are a 
proper superset of those found by the first one. What's wrong here? Why does 
a search for 'merge-base' not find occurences of 'builtin-merge-base'?

-- Hannes

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox