Git development
 help / color / mirror / Atom feed
* Re: cvs import
From: Oswald Buddenhagen @ 2006-09-16  6:04 UTC (permalink / raw)
  To: Shawn Pearce
  Cc: Markus Schiltknecht, Michael Haggerty, Jon Smirl, Martin Langhoff,
	Git Mailing List, monotone-devel, dev
In-Reply-To: <20060916033917.GA24269@spearce.org>

On Fri, Sep 15, 2006 at 11:39:18PM -0400, Shawn Pearce wrote:
> On the other hand from what I understand of Monotone it needs
> the revisions in oldest->newest order, as does SVN.
> 
> Doing both orderings in cvs2noncvs is probably ugly.
>
don't worry, as i know mike, he'll come up with an abstract, outright
beautiful interface that makes you want to implement middle->oldnewest
just for the sake of doing it. :)

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.

^ permalink raw reply

* Re: [PATCH] Skip t3403 selftests if stdin is not a terminal
From: Junio C Hamano @ 2006-09-16  6:19 UTC (permalink / raw)
  To: Gerrit Pape; +Cc: git, Lukas Sandström
In-Reply-To: <7vk644e5f5.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano <junkio@cox.net> writes:

> Gerrit Pape <pape@smarden.org> writes:
>
>> sh t3403-rebase-skip.sh </dev/null fails because stdin is not connected
>> to a terminal, as in the Debian autobuild environment.  This disbales
>> the test 3 and 7 in this case.
>
> Disabling these tests somehow feels as if you are shooting the
> messenger who reports breakage of the commands they try to test.
>
> Is it expected that the git Porcelainish commands involved in
> these particular tests not to work without terminal?  If not
> maybe we should fix them, not the test.

How about this instead?

-- >8 --
Fix git-am safety checks

An earlier commit cbd64af added a check that prevents "git-am"
to run without its standard input connected to a terminal while
resuming operation.  This was to catch a user error to try
feeding a new patch from its standard input while recovery.

The assumption of the check was that it is an indication that a
new patch is being fed if the standard input is not connected to
a terminal.  It is however not quite correct (the standard input
can be /dev/null if the user knows the operation does not need
any input, for example).  This broke t3403 when the test was run
with its standard input connected to /dev/null.

When git-am is given an explicit command such as --skip, there
is no reason to insist that the standard input is a terminal; we
are not going to read a new patch anyway.

Credit goes to Gerrit Pape for noticing and reporting the
problem with t3403-rebase-skip test.

---
diff --git a/git-am.sh b/git-am.sh
index d0af786..66a8e3d 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -166,10 +166,25 @@ fi
 
 if test -d "$dotest"
 then
-	if test ",$#," != ",0," || ! tty -s
-	then
-		die "previous dotest directory $dotest still exists but mbox given."
-	fi
+	case "$#,$skip$resolved" in    
+	0,*t*)
+		# Explicit resume command and we do not have file, so
+		# we are happy.
+		: ;;
+	0,)
+		# No file input but without resume parameters; catch
+		# user error to feed us a patch from standard input
+		# when there is already .dotest.  This is somewhat
+		# unreliable -- stdin could be /dev/null for example
+		# and the caller did not intend to feed us a patch but
+		# wanted to continue unattended.
+		tty -s
+		;;
+	*)
+		false
+		;;
+	esac ||
+	die "previous dotest directory $dotest still exists but mbox given."
 	resume=yes
 else
 	# Make sure we are not given --skip nor --resolved

^ permalink raw reply related

* Re: Re: cvs import
From: Nathaniel Smith @ 2006-09-16  6:21 UTC (permalink / raw)
  To: Shawn Pearce
  Cc: Martin Langhoff, monotone-devel, Jon Smirl, dev, Git Mailing List
In-Reply-To: <20060916033917.GA24269@spearce.org>

On Fri, Sep 15, 2006 at 11:39:18PM -0400, Shawn Pearce wrote:
> On the other hand from what I understand of Monotone it needs
> the revisions in oldest->newest order, as does SVN.

Monotone stores file deltas new->old, similar to git.  It should be
reasonably efficient at turning them around if it has to, though -- so
long as you give all the versions of a single file at a time, so
there's some reasonable locality, instead of jumping all around the
tree.

-- Nathaniel

-- 
"...All of this suggests that if we wished to find a modern-day model
for British and American speech of the late eighteenth century, we could
probably do no better than Yosemite Sam."

^ permalink raw reply

* Re: [PATCH] Trivial support for cloning and fetching via ftp://.
From: Junio C Hamano @ 2006-09-16  9:12 UTC (permalink / raw)
  To: Sasha Khapyorsky; +Cc: git
In-Reply-To: <20060916023717.GA13570@sashak.voltaire.com>

Sasha Khapyorsky <sashak@voltaire.com> writes:

> Something like this?
>
> With this change I'm able to clone
> ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git

I think without you would have, just with extra error messages
that http codepath filters out.

> diff --git a/http-fetch.c b/http-fetch.c
> index a113bb8..46d6029 100644
> --- a/http-fetch.c
> +++ b/http-fetch.c
> @@ -324,7 +324,9 @@ static void process_object_response(void
>  
>  	/* Use alternates if necessary */
>  	if (obj_req->http_code == 404 ||
> -	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
> +	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE ||
> +	    (obj_req->http_code == 550 &&
> +	     obj_req->curl_result == CURLE_FTP_COULDNT_RETR_FILE)) {

Here you do the same as the code would for HTTP 404 when you get
550 _and_ RETR failure...

> @@ -538,7 +540,9 @@ static void process_alternates_response(
>  		}
>  	} else if (slot->curl_result != CURLE_OK) {
>  		if (slot->http_code != 404 &&
> -		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {
> +		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE &&
> +		    (slot->http_code != 550 &&
> +		     slot->curl_result != CURLE_FTP_COULDNT_RETR_FILE)) {
>  			got_alternates = -1;

... but you say, while the original code says "declare error if
it is not HTTP 404", "oh by the way, if it is 550 _or_ if it
is RETR failure then do not trigger this if()".  I suspect you
meant to say this?

	    (slot->http_code != 550 ||
	     slot->curl_result != CURLE_FTP_COULDNT_RETR_FILE)) {

^ permalink raw reply

* Re: Teach "git checkout" to use git-show-ref
From: Junio C Hamano @ 2006-09-16  9:33 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0609151455150.4388@g5.osdl.org>

Linus Torvalds <torvalds@osdl.org> writes:

> That way, it doesn't care how the refs are stored any more
>
> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
> ---
>
> Just as an example of how to use git-show-ref rather than knowing about 
> "$GIT_DIR/refs/..." paths.
>
> This basically replaces my much hackier version that is in the "lt/refs" 
> branch, but can go into the master branch independently of the 
> refs-packing work.

I kind of liked the rev-parse one better for this particular
command, but only slightly (by using --verify on "$arg^0", you
were also making sure what's in refs/heads/ was a commit object,
but that check is gone with this patch.  It is not a loss,
because the original code did not check it, and nobody should be
placing anything but commits under refs/heads anyway).

> diff --git a/git-checkout.sh b/git-checkout.sh
> index 580a9e8..6e4c535 100755
> --- a/git-checkout.sh
> +++ b/git-checkout.sh
>...
> @@ -51,7 +51,7 @@ while [ "$#" != "0" ]; do
>  			fi
>  			new="$rev"
>  			new_name="$arg^0"
> -			if [ -f "$GIT_DIR/refs/heads/$arg" ]; then
> +			if git-show-ref --verify --quiet -- "refs/heads/$arg" ]; then
>  				branch="$arg"
>  			fi
>  		elif rev=$(git-rev-parse --verify "$arg^{tree}" 2>/dev/null)

^ permalink raw reply

* Re: [PATCH] Trivial support for cloning and fetching via ftp://.
From: Sasha Khapyorsky @ 2006-09-16 10:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vwt849nv6.fsf@assigned-by-dhcp.cox.net>

On 02:12 Sat 16 Sep     , Junio C Hamano wrote:
> Sasha Khapyorsky <sashak@voltaire.com> writes:
> 
> > Something like this?
> >
> > With this change I'm able to clone
> > ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git
> 
> I think without you would have, just with extra error messages
> that http codepath filters out.

No, not really, without change it fails later:

$ git-clone ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git
error: RETR response: 550 (curl_result = 19, http_code = 550, sha1 = 63b98080daa35f0d682db04f4fb7ada010888752)
Getting pack list for ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/
Getting alternates list for ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/
Also look at ftp://ftp.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/
Getting pack list for ftp://ftp.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/
Getting index for pack 477061883bee3d10bece6e3432355b61ba02e594
error: Unable to find 63b98080daa35f0d682db04f4fb7ada010888752 under ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/
Cannot obtain needed none 63b98080daa35f0d682db04f4fb7ada010888752
while processing commit 0000000000000000000000000000000000000000.

> 
> > diff --git a/http-fetch.c b/http-fetch.c
> > index a113bb8..46d6029 100644
> > --- a/http-fetch.c
> > +++ b/http-fetch.c
> > @@ -324,7 +324,9 @@ static void process_object_response(void
> >  
> >  	/* Use alternates if necessary */
> >  	if (obj_req->http_code == 404 ||
> > -	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
> > +	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE ||
> > +	    (obj_req->http_code == 550 &&
> > +	     obj_req->curl_result == CURLE_FTP_COULDNT_RETR_FILE)) {
> 
> Here you do the same as the code would for HTTP 404 when you get
> 550 _and_ RETR failure...
> 
> > @@ -538,7 +540,9 @@ static void process_alternates_response(
> >  		}
> >  	} else if (slot->curl_result != CURLE_OK) {
> >  		if (slot->http_code != 404 &&
> > -		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {
> > +		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE &&
> > +		    (slot->http_code != 550 &&
> > +		     slot->curl_result != CURLE_FTP_COULDNT_RETR_FILE)) {
> >  			got_alternates = -1;
> 
> ... but you say, while the original code says "declare error if
> it is not HTTP 404", "oh by the way, if it is 550 _or_ if it
> is RETR failure then do not trigger this if()".  I suspect you
> meant to say this?
> 
> 	    (slot->http_code != 550 ||
> 	     slot->curl_result != CURLE_FTP_COULDNT_RETR_FILE)) {

I think with less strict checking this could be done so, but with _and_
this also ensures that we are really in FTP mode.

Sasha

^ permalink raw reply

* Re: [PATCH] Trivial support for cloning and fetching via ftp://.
From: Sasha Khapyorsky @ 2006-09-16 10:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <20060916100147.GA17504@sashak.voltaire.com>

On 13:01 Sat 16 Sep     , Sasha Khapyorsky wrote:
> On 02:12 Sat 16 Sep     , Junio C Hamano wrote:
> > Sasha Khapyorsky <sashak@voltaire.com> writes:
> > 
> > > Something like this?
> > >
> > > With this change I'm able to clone
> > > ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git
> > 
> > I think without you would have, just with extra error messages
> > that http codepath filters out.
> 
> No, not really, without change it fails later:
> 
> $ git-clone ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git
> error: RETR response: 550 (curl_result = 19, http_code = 550, sha1 = 63b98080daa35f0d682db04f4fb7ada010888752)
> Getting pack list for ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/
> Getting alternates list for ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/
> Also look at ftp://ftp.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/
> Getting pack list for ftp://ftp.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/
> Getting index for pack 477061883bee3d10bece6e3432355b61ba02e594
> error: Unable to find 63b98080daa35f0d682db04f4fb7ada010888752 under ftp://ftp.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/
> Cannot obtain needed none 63b98080daa35f0d682db04f4fb7ada010888752
> while processing commit 0000000000000000000000000000000000000000.
> 
> > 
> > > diff --git a/http-fetch.c b/http-fetch.c
> > > index a113bb8..46d6029 100644
> > > --- a/http-fetch.c
> > > +++ b/http-fetch.c
> > > @@ -324,7 +324,9 @@ static void process_object_response(void
> > >  
> > >  	/* Use alternates if necessary */
> > >  	if (obj_req->http_code == 404 ||
> > > -	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
> > > +	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE ||
> > > +	    (obj_req->http_code == 550 &&
> > > +	     obj_req->curl_result == CURLE_FTP_COULDNT_RETR_FILE)) {
> > 
> > Here you do the same as the code would for HTTP 404 when you get
> > 550 _and_ RETR failure...
> > 
> > > @@ -538,7 +540,9 @@ static void process_alternates_response(
> > >  		}
> > >  	} else if (slot->curl_result != CURLE_OK) {
> > >  		if (slot->http_code != 404 &&
> > > -		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {
> > > +		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE &&
> > > +		    (slot->http_code != 550 &&
> > > +		     slot->curl_result != CURLE_FTP_COULDNT_RETR_FILE)) {
> > >  			got_alternates = -1;
> > 
> > ... but you say, while the original code says "declare error if
> > it is not HTTP 404", "oh by the way, if it is 550 _or_ if it
> > is RETR failure then do not trigger this if()".  I suspect you
> > meant to say this?
> > 
> > 	    (slot->http_code != 550 ||
> > 	     slot->curl_result != CURLE_FTP_COULDNT_RETR_FILE)) {
> 
> I think with less strict checking this could be done so, but with _and_
> this also ensures that we are really in FTP mode.

Hmm, saying this I see that original code doesn't do it for specific
case. So for this case we could do:

 	    !(slot->http_code == 550 &&
 	     slot->curl_result == CURLE_FTP_COULDNT_RETR_FILE)) {

Sasha

^ permalink raw reply

* Re: [PATCH] cg-commit: prefix the relative path to the message file
From: Jim Meyering @ 2006-09-16 15:07 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: git
In-Reply-To: <20060825000614.GF2817@diku.dk>

Jonas Fonseca <fonseca@diku.dk> wrote:
> Makes the -M switch work from a subdirectory.
>
> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
>
> ---
>
> Jim Meyering <jim@meyering.net> wrote Wed, Aug 23, 2006:
>> Hello,
>
> Hi,
>
>> I discovered that "cg-commit -M MSG-FILE ..." fails when run from
>> a subdirectory, and when MSG-FILE is a relative file name.
>> This is using cogito-0.17.3-2 from Debian/unstable, but the problem
>> remains when using the latest cogito sources, pulled minutes ago.
>
> The attached patch should fix this problem.
>
> ---
>
>  cg-commit |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/cg-commit b/cg-commit
> index 0cec58f..5cebd81 100755
> --- a/cg-commit
> +++ b/cg-commit
> @@ -398,7 +398,7 @@ fi
>
>  if [ "$msgfile" ]; then
>  	[ "$written" ] && echo >>"$LOGMSG"
> -	cat "$msgfile" >>"$LOGMSG" || exit 1
> +	cat "$_git_relpath$msgfile" >>"$LOGMSG" || exit 1
>  	written=1
>  fi
>
>

Thank you!
That solved the problem for me.

^ permalink raw reply

* Re: [PATCH] cg-commit: Fix a typo that would inhibit running of post-commit script:
From: Jim Meyering @ 2006-09-16 15:10 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: git
In-Reply-To: <20060825002013.GG2817@diku.dk>

Jonas Fonseca <fonseca@diku.dk> wrote:
> Jim Meyering <jim@meyering.net> wrote Thu, Aug 24, 2006:
>> I tried cg-commit with a commit hook, but the hook never ran.
>> The problem was a typo:
>>
>> Fix a typo that would inhibit running the post-commit script:
>> s/commit-post/post-commit/.
>
> If I remember correctly, historically, the commit-post existed before
> the post-commit appeared. You can see that it is documented in the man
> page so it is not a typo.
>
> However, this should certainly be updated, but I think a better fix
> would be to transitionally warn the user about the existence of the
> commit-post hook before using it in favour of post-commit.

How about this?
Check for both and if there's exactly one, use that.
If it's the old one, give a diagnostic suggesting to rename it.
If both exist, execute neither, give a diagnostic and fail.

If you like this, I'll prepare a patch.

>> diff --git a/cg-commit b/cg-commit
>> index 9d3b1a1..82eea60 100755
>> --- a/cg-commit
>> +++ b/cg-commit
>> @@ -604,15 +604,16 @@ if [ "$newhead" ]; then
>>  		branchname="$(cat "$_git/branch-name")"
>>  	fi
>>  	[ -z "$branchname" ] && [ "$_git_head" != "master" ] && branchname="$_git_head"
>> -	if [ -x "$_git/hooks/post-commit" -a ! "$no_hooks" ]; then
>> +	post_commit="$_git/hooks/post-commit"
>> +	if [ -x "$post_commit" -a ! "$no_hooks" ]; then
>>  		if [ "$(git-repo-config --bool cogito.hooks.commit.post.allmerged)" = "true" ]; then
>>  			# We just hope that for the initial commit, the user didn't
>>  			# manage to install the hook yet.
>>  			for merged in $(git-rev-list $newhead ^$oldhead | tac); do
>> -				"$_git/hooks/post-commit" "$merged" "$branchname"
>> +				"$post_commit" "$merged" "$branchname"
>>  			done
>>  		else
>> -			"$_git/hooks/post-commit" "$newhead" "$branchname"
>> +			"$post_commit" "$newhead" "$branchname"
>>  		fi
>>  	fi
>
> The patch looks more like a refactoring of a previous commit that did
> the commit-post -> post-commit replacement.

Exactly :)

^ permalink raw reply

* Re: [PATCH] Trivial support for cloning and fetching via ftp://.
From: Junio C Hamano @ 2006-09-16 17:29 UTC (permalink / raw)
  To: Sasha Khapyorsky; +Cc: git
In-Reply-To: <20060916100147.GA17504@sashak.voltaire.com>

Sasha Khapyorsky <sashak@voltaire.com> writes:

>> > diff --git a/http-fetch.c b/http-fetch.c
>> > index a113bb8..46d6029 100644
>> > --- a/http-fetch.c
>> > +++ b/http-fetch.c
>> > @@ -324,7 +324,9 @@ static void process_object_response(void
>> >  
>> >  	/* Use alternates if necessary */
>> >  	if (obj_req->http_code == 404 ||
>> > -	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
>> > +	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE ||
>> > +	    (obj_req->http_code == 550 &&
>> > +	     obj_req->curl_result == CURLE_FTP_COULDNT_RETR_FILE)) {
>> 
>> Here you do the same as the code would for HTTP 404 when you get
>> 550 _and_ RETR failure...
>> 
>> > @@ -538,7 +540,9 @@ static void process_alternates_response(
>> >  		}
>> >  	} else if (slot->curl_result != CURLE_OK) {
>> >  		if (slot->http_code != 404 &&
>> > -		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {
>> > +		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE &&
>> > +		    (slot->http_code != 550 &&
>> > +		     slot->curl_result != CURLE_FTP_COULDNT_RETR_FILE)) {
>> >  			got_alternates = -1;
>> 
>> ... but you say, while the original code says "declare error if
>> it is not HTTP 404", "oh by the way, if it is 550 _or_ if it
>> is RETR failure then do not trigger this if()".  I suspect you
>> meant to say this?
>> 
>> 	    (slot->http_code != 550 ||
>> 	     slot->curl_result != CURLE_FTP_COULDNT_RETR_FILE)) {
>
> I think with less strict checking this could be done so, but with _and_
> this also ensures that we are really in FTP mode.

I was merely pointing out that in one place you have:

	(http_code == 550 && result == ERETR)

and another place that tries to say the opposite you have:

	(http_code != 550 && result != ERETR)

which is not the same thing as

	!(http_code == 550 && result == ERETR)

I understood, from the former "Use alternates if necessary"
part, that you wanted to make sure that 550 is really from
FTP_RETR and not other random HTTP error message, and I think
that is a reasonable thing to do.

^ permalink raw reply

* Re: [PATCH] Trivial support for cloning and fetching via ftp://.
From: Sasha Khapyorsky @ 2006-09-16 17:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7virjnafev.fsf@assigned-by-dhcp.cox.net>

On 10:29 Sat 16 Sep     , Junio C Hamano wrote:
> Sasha Khapyorsky <sashak@voltaire.com> writes:
> 
> >> > diff --git a/http-fetch.c b/http-fetch.c
> >> > index a113bb8..46d6029 100644
> >> > --- a/http-fetch.c
> >> > +++ b/http-fetch.c
> >> > @@ -324,7 +324,9 @@ static void process_object_response(void
> >> >  
> >> >  	/* Use alternates if necessary */
> >> >  	if (obj_req->http_code == 404 ||
> >> > -	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
> >> > +	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE ||
> >> > +	    (obj_req->http_code == 550 &&
> >> > +	     obj_req->curl_result == CURLE_FTP_COULDNT_RETR_FILE)) {
> >> 
> >> Here you do the same as the code would for HTTP 404 when you get
> >> 550 _and_ RETR failure...
> >> 
> >> > @@ -538,7 +540,9 @@ static void process_alternates_response(
> >> >  		}
> >> >  	} else if (slot->curl_result != CURLE_OK) {
> >> >  		if (slot->http_code != 404 &&
> >> > -		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {
> >> > +		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE &&
> >> > +		    (slot->http_code != 550 &&
> >> > +		     slot->curl_result != CURLE_FTP_COULDNT_RETR_FILE)) {
> >> >  			got_alternates = -1;
> >> 
> >> ... but you say, while the original code says "declare error if
> >> it is not HTTP 404", "oh by the way, if it is 550 _or_ if it
> >> is RETR failure then do not trigger this if()".  I suspect you
> >> meant to say this?
> >> 
> >> 	    (slot->http_code != 550 ||
> >> 	     slot->curl_result != CURLE_FTP_COULDNT_RETR_FILE)) {
> >
> > I think with less strict checking this could be done so, but with _and_
> > this also ensures that we are really in FTP mode.
> 
> I was merely pointing out that in one place you have:
> 
> 	(http_code == 550 && result == ERETR)
> 
> and another place that tries to say the opposite you have:
> 
> 	(http_code != 550 && result != ERETR)
> 
> which is not the same thing as
> 
> 	!(http_code == 550 && result == ERETR)
> 
> I understood, from the former "Use alternates if necessary"
> part, that you wanted to make sure that 550 is really from
> FTP_RETR and not other random HTTP error message, and I think
> that is a reasonable thing to do.

Good. Am I need to send the patch or you will integrate it?

Sasha

^ permalink raw reply

* Re: [PATCH] Trivial support for cloning and fetching via ftp://.
From: Junio C Hamano @ 2006-09-16 17:58 UTC (permalink / raw)
  To: Sasha Khapyorsky; +Cc: git
In-Reply-To: <20060916174134.GE17504@sashak.voltaire.com>

Sasha Khapyorsky <sashak@voltaire.com> writes:

> Good. Am I need to send the patch or you will integrate it?

Actually, I am thinking of doing this in two steps.

The attached is the first "clean-up" step, which should be
obvious enough.

And you already know what the second one that would come on top
of this should look like ;-).

-- >8 --
http-fetch.c: consolidate code to detect missing fetch target

At a handful places we check two error codes from curl library
to see if the file we asked was missing from the remote (e.g.
we asked for a loose object when it is in a pack) to decide what
to do next.  This consolidates the check into a single function.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/http-fetch.c b/http-fetch.c
index a113bb8..bc74f30 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -144,6 +144,19 @@ static size_t fwrite_sha1_file(void *ptr
 	return size;
 }
 
+static int missing__target(int code, int result)
+{
+	return	/* file:// URL -- do we ever use one??? */
+		(result == CURLE_FILE_COULDNT_READ_FILE) ||
+		/* http:// and https:// URL */
+		(code == 404 && result == CURLE_HTTP_RETURNED_ERROR) ||
+		/* ftp:// URL */
+		(code == 550 && result == CURLE_FTP_COULDNT_RETR_FILE)
+		;
+}
+
+#define missing_target(a) missing__target((a)->http_code, (a)->curl_result)
+
 static void fetch_alternates(const char *base);
 
 static void process_object_response(void *callback_data);
@@ -323,8 +336,7 @@ static void process_object_response(void
 	obj_req->state = COMPLETE;
 
 	/* Use alternates if necessary */
-	if (obj_req->http_code == 404 ||
-	    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
+	if (missing_target(obj_req)) {
 		fetch_alternates(alt->base);
 		if (obj_req->repo->next != NULL) {
 			obj_req->repo =
@@ -537,8 +549,7 @@ static void process_alternates_response(
 			return;
 		}
 	} else if (slot->curl_result != CURLE_OK) {
-		if (slot->http_code != 404 &&
-		    slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {
+		if (!missing_target(slot)) {
 			got_alternates = -1;
 			return;
 		}
@@ -941,8 +952,7 @@ #endif
 	if (start_active_slot(slot)) {
 		run_active_slot(slot);
 		if (results.curl_result != CURLE_OK) {
-			if (results.http_code == 404 ||
-			    results.curl_result == CURLE_FILE_COULDNT_READ_FILE) {
+			if (missing_target(&results)) {
 				repo->got_indices = 1;
 				free(buffer.buffer);
 				return 0;
@@ -1123,8 +1133,7 @@ #endif
 		ret = error("Request for %s aborted", hex);
 	} else if (obj_req->curl_result != CURLE_OK &&
 		   obj_req->http_code != 416) {
-		if (obj_req->http_code == 404 ||
-		    obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE)
+		if (missing_target(obj_req))
 			ret = -1; /* Be silent, it is probably in a pack. */
 		else
 			ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",

^ permalink raw reply related

* Re: nightly tarballs of git
From: Dave Jones @ 2006-09-16 17:58 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7virjq2oyc.fsf@assigned-by-dhcp.cox.net>

On Thu, Sep 14, 2006 at 01:06:03PM -0700, Junio C Hamano wrote:

 > If you are using git-tar-tree (which by the way _is_ the right
 > thing to do) and if you are just taking an upstream snapshot
 > without doing your own development (which also is the case
 > here), then you do not even need a working tree in the directory
 > this script runs.  It would save your disk space and time to
 > check out the updated working tree files.
 > 
 > Perhaps...
 > 
 > #!/bin/sh
 > URL=git://git.kernel.org/pub/scm/git/git.git
 > PROJ=git
 > 
 > cd ~/git-trees
 > if test -d "$PROJ"
 > then
 > 	cd "$PROJ" && git fetch
 > else
 > 	git clone -q -n "$URL" "$PROJ" && cd "$PROJ"
 > fi || {
 > 	echo >&2 Something wicked happend.
 >         exit $?
 > }
 > snap=git-snapshot-$(date +"%Y%m%d")
 > git-tar-tree origin $snap | gzip -9 > $PROJ-$DATE.tar.gz

This went well, right up until you checked something in :-)

Generating pack...
Done counting 155 objects.
Result has 126 objects.
Deltifying 126 objects.
   0% (1/126) done
   1% (2/126) done
   2% (3/126) done
   3% (4/126) done
   4% (6/126) done
   5% (7/126) done
   6% (8/126) done
   7% (9/126) done
   8% (11/126) done
   9% (12/126) done
  10% (13/126) done
  11% (14/126) done
  12% (16/126) done
  13% (17/126) done
  14% (18/126) done
  15% (19/126) done
  16% (21/126) done
  17% (22/126) done
  18% (23/126) done
  19% (24/126) done
  20% (26/126) done
  21% (27/126) done
  22% (28/126) done
  23% (29/126) done
  24% (31/126) done
  25% (32/126) done
  26% (33/126) done
  27% (35/126) done
  28% (36/126) done
  29% (37/126) done
  30% (38/126) done
  31% (40/126) done
  32% (41/126) done
  33% (42/126) done
  34% (43/126) done
  35% (45/126) done
  36% (46/126) done
  37% (47/126) done
  38% (48/126) done
  39% (50/126) done
  40% (51/126) done
  41% (52/126) done
  42% (53/126) done
  43% (55/126) done
  44% (56/126) done
  45% (57/126) done
  46% (58/126) done
  47% (60/126) done
  48% (61/126) done
  49% (62/126) done
  50% (63/126) done
  51% (65/126) done
  52% (66/126) done
  53% (67/126) done
  54% (69/126) done
  55% (70/126) done
  56% (71/126) done
  57% (72/126) done
  58% (74/126) done
  59% (75/126) done
  60% (76/126) done
  61% (77/126) done
  62% (79/126) done
  63% (80/126) done
  64% (81/126) done
  65% (82/126) done
  66% (84/126) done
  67% (85/126) done
  68% (86/126) done
  69% (87/126) done
  70% (89/126) done
  71% (90/126) done
  72% (91/126) done
  73% (92/126) done
  74% (94/126) done
  75% (95/126) done
  76% (96/126) done
  77% (98/126) done
  78% (99/126) done
  79% (100/126) done
  80% (101/126) done
  81% (103/126) done
  82% (104/126) done
  83% (105/126) done
  84% (106/126) done
  85% (108/126) done
  86% (109/126) done
  87% (110/126) done
  88% (111/126) done
  89% (113/126) done
  90% (114/126) done
  91% (115/126) done
  92% (116/126) done
  93% (118/126) done
  94% (119/126) done
  95% (120/126) done
  96% (121/126) done
  97% (123/126) done
  98% (124/126) done
  99% (125/126) done
 100% (126/126) done
Unpacking 126 objects
Total 126, written 126 (delta 93), reused 0 (delta 0)
* refs/heads/origin: fast forward to branch 'master' of git://git.kernel.org/pub/scm/git/git
  from 38529e28a4f465ad5d5f2fa249ca17da680bac5f to fc2b2be031f44aef0106cf7f872b750cd90b2253
* refs/heads/pu: does not fast forward to branch 'pu' of git://git.kernel.org/pub/scm/git/git;
  not updating.
Something wicked happend.



		Dave

-- 
http://www.codemonkey.org.uk

^ permalink raw reply

* Re: [PATCH] Trivial support for cloning and fetching via ftp://.
From: Junio C Hamano @ 2006-09-16 18:00 UTC (permalink / raw)
  To: Sasha Khapyorsky; +Cc: git
In-Reply-To: <7vd59vae2r.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano <junkio@cox.net> writes:

> Sasha Khapyorsky <sashak@voltaire.com> writes:
>
>> Good. Am I need to send the patch or you will integrate it?
>
> Actually, I am thinking of doing this in two steps.
>
> The attached is the first "clean-up" step, which should be
> obvious enough.
>
> And you already know what the second one that would come on top
> of this should look like ;-).

Oops, thinko.  I sent a rolled-up one out.

^ permalink raw reply

* Re: nightly tarballs of git
From: Jakub Narebski @ 2006-09-16 18:04 UTC (permalink / raw)
  To: git
In-Reply-To: <20060916175853.GA24124@redhat.com>

Dave Jones wrote:

> * refs/heads/pu: does not fast forward to branch 'pu' of
>   git://git.kernel.org/pub/scm/git/git; 
>   not updating.
> Something wicked happend.
 
Did you put '+' before 'pu' line in 'origin' file in remotes?
It should read

        Pull:+refs/heads/pu:refs/heads/pu

Alternatively you can give --force option to git-fetch.

See
http://git.or.cz/gitwiki/GitFaq#head-a1f9a3e511e0b866d788d7cb600637a9b976a994
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* Re: nightly tarballs of git
From: Junio C Hamano @ 2006-09-16 18:09 UTC (permalink / raw)
  To: Dave Jones; +Cc: git
In-Reply-To: <20060916175853.GA24124@redhat.com>

Dave Jones <davej@redhat.com> writes:

> This went well, right up until you checked something in :-)
>
> Generating pack...
> Done counting 155 objects.
> Result has 126 objects.
> Deltifying 126 objects.
>    0% (1/126) done
> ...
> Unpacking 126 objects
> Total 126, written 126 (delta 93), reused 0 (delta 0)
> * refs/heads/origin: fast forward to branch 'master' of git://git.kernel.org/pub/scm/git/git
>   from 38529e28a4f465ad5d5f2fa249ca17da680bac5f to fc2b2be031f44aef0106cf7f872b750cd90b2253
> * refs/heads/pu: does not fast forward to branch 'pu' of git://git.kernel.org/pub/scm/git/git;
>   not updating.
> Something wicked happend.

You care only about 'master' in that repository anyway, so I
would suggest removing other lines from remotes/origin and have
only these two lines:

	URL:  git://git.kernel.org/pub/scm/git/git
        Pull: refs/heads/master:refs/heads/origin

^ permalink raw reply

* [PATCH] git-tar-tree: devolve git-tar-tree into a wrapper for git-archive
From: Rene Scharfe @ 2006-09-16 19:20 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Franck Bui-Huu, Git Mailing List

This patch removes the custom tree walker tree_traverse(), and makes
generate_tar() use write_tar_archive() and the infrastructure provided
by git-archive instead.

As a kind of side effect, make write_tar_archive() able to handle NULL
as base directory, as this is what the new and simple generate_tar()
uses to indicate the absence of a base directory.  This was simpler
and cleaner than playing tricks with empty strings.

The behaviour of git-tar-tree should be unchanged (quick tests didn't
indicate otherwise) except for the text of some error messages.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---

 builtin-tar-tree.c |   90 ++++++++++-------------------------------------------
 1 file changed, 18 insertions(+), 72 deletions(-)

diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index f2679a8..437eb72 100644
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
@@ -3,7 +3,6 @@
  */
 #include <time.h>
 #include "cache.h"
-#include "tree-walk.h"
 #include "commit.h"
 #include "strbuf.h"
 #include "tar.h"
@@ -248,37 +247,6 @@ static void write_global_extended_header
 	free(ext_header.buf);
 }
 
-static void traverse_tree(struct tree_desc *tree, struct strbuf *path)
-{
-	int pathlen = path->len;
-	struct name_entry entry;
-
-	while (tree_entry(tree, &entry)) {
-		void *eltbuf;
-		char elttype[20];
-		unsigned long eltsize;
-
-		eltbuf = read_sha1_file(entry.sha1, elttype, &eltsize);
-		if (!eltbuf)
-			die("cannot read %s", sha1_to_hex(entry.sha1));
-
-		path->len = pathlen;
-		strbuf_append_string(path, entry.path);
-		if (S_ISDIR(entry.mode))
-			strbuf_append_string(path, "/");
-
-		write_entry(entry.sha1, path, entry.mode, eltbuf, eltsize);
-
-		if (S_ISDIR(entry.mode)) {
-			struct tree_desc subtree;
-			subtree.buf = eltbuf;
-			subtree.size = eltsize;
-			traverse_tree(&subtree, path);
-		}
-		free(eltbuf);
-	}
-}
-
 static int git_tar_config(const char *var, const char *value)
 {
 	if (!strcmp(var, "tar.umask")) {
@@ -295,51 +263,29 @@ static int git_tar_config(const char *va
 
 static int generate_tar(int argc, const char **argv, const char *prefix)
 {
-	unsigned char sha1[20], tree_sha1[20];
-	struct commit *commit;
-	struct tree_desc tree;
-	struct strbuf current_path;
-	void *buffer;
-
-	current_path.buf = xmalloc(PATH_MAX);
-	current_path.alloc = PATH_MAX;
-	current_path.len = current_path.eof = 0;
+	struct archiver_args args;
+	int result;
+	char *base = NULL;
 
 	git_config(git_tar_config);
 
-	switch (argc) {
-	case 3:
-		strbuf_append_string(&current_path, argv[2]);
-		strbuf_append_string(&current_path, "/");
-		/* FALLTHROUGH */
-	case 2:
-		if (get_sha1(argv[1], sha1))
-			die("Not a valid object name %s", argv[1]);
-		break;
-	default:
+	memset(&args, 0, sizeof(args));
+	if (argc != 2 && argc != 3)
 		usage(tar_tree_usage);
+	if (argc == 3) {
+		int baselen = strlen(argv[2]);
+		base = xmalloc(baselen + 2);
+		memcpy(base, argv[2], baselen);
+		base[baselen] = '/';
+		base[baselen + 1] = '\0';
 	}
+	args.base = base;
+	parse_treeish_arg(argv + 1, &args, NULL);
 
-	commit = lookup_commit_reference_gently(sha1, 1);
-	if (commit) {
-		write_global_extended_header(commit->object.sha1);
-		archive_time = commit->date;
-	} else
-		archive_time = time(NULL);
-
-	tree.buf = buffer = read_object_with_reference(sha1, tree_type,
-	                                               &tree.size, tree_sha1);
-	if (!tree.buf)
-		die("not a reference to a tag, commit or tree object: %s",
-		    sha1_to_hex(sha1));
-
-	if (current_path.len > 0)
-		write_entry(tree_sha1, &current_path, 040777, NULL, 0);
-	traverse_tree(&tree, &current_path);
-	write_trailer();
-	free(buffer);
-	free(current_path.buf);
-	return 0;
+	result = write_tar_archive(&args);
+	free(base);
+
+	return result;
 }
 
 static int write_tar_entry(const unsigned char *sha1,
@@ -383,7 +329,7 @@ static int write_tar_entry(const unsigne
 
 int write_tar_archive(struct archiver_args *args)
 {
-	int plen = strlen(args->base);
+	int plen = args->base ? strlen(args->base) : 0;
 
 	git_config(git_tar_config);
 

^ permalink raw reply related

* [PATCH] gitweb: export-ok option
From: Matthias Lederhofer @ 2006-09-16 19:27 UTC (permalink / raw)
  To: git

Similar to git-daemon checking for git-daemon-export-ok this
introduces an optional check before showing a repository in gitweb.

I also changed the 'No such directory' error message to 'No such
project' because the user visiting my gitweb should not know what
directories I have in the project root directory.

undef $project; is used to prevent displaying the description.
---
Perhaps there should be another option which allows only those
repositories to be shown which are in $projects_list.
---
 Makefile           |    2 ++
 gitweb/gitweb.perl |   18 ++++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 7b3114f..63df24c 100644
--- a/Makefile
+++ b/Makefile
@@ -132,6 +132,7 @@ GITWEB_HOMETEXT = indextext.html
 GITWEB_CSS = gitweb.css
 GITWEB_LOGO = git-logo.png
 GITWEB_FAVICON = git-favicon.png
+GITWEB_EXPORT_OK =
 
 export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
 
@@ -637,6 +638,7 @@ 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_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
 	    $< >$@+
 	chmod +x $@+
 	mv $@+ $@
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d89f709..3944d13 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -54,6 +54,9 @@ our $favicon = "++GITWEB_FAVICON++";
 # source of projects list
 our $projects_list = "++GITWEB_LIST++";
 
+# show repository only if this file exists
+our $export_ok = "++GITWEB_EXPORT_OK++";
+
 # list of git base URLs used for URL to where fetch project from,
 # i.e. full URL is "$git_base_url/$project"
 our @git_base_url_list = ("++GITWEB_BASE_URL++");
@@ -181,12 +184,13 @@ if (defined $project) {
 }
 if (defined $project) {
 	if (!validate_input($project)) {
+		undef $project;
 		die_error(undef, "Invalid project parameter");
 	}
-	if (!(-d "$projectroot/$project")) {
-		die_error(undef, "No such directory");
-	}
-	if (!(-e "$projectroot/$project/HEAD")) {
+	if (!(-d "$projectroot/$project") ||
+	    !(-e "$projectroot/$project/HEAD") ||
+	    ($export_ok && !(-e "$projectroot/$project/$export_ok"))) {
+		undef $project;
 		die_error(undef, "No such project");
 	}
 	$git_dir = "$projectroot/$project";
@@ -694,7 +698,8 @@ sub git_get_projects_list {
 		my $dir = $projects_list;
 		opendir my ($dh), $dir or return undef;
 		while (my $dir = readdir($dh)) {
-			if (-e "$projectroot/$dir/HEAD") {
+			if (-e "$projectroot/$dir/HEAD" && (!$export_ok ||
+			    -e "$projectroot/$dir/$export_ok")) {
 				my $pr = {
 					path => $dir,
 				};
@@ -716,7 +721,8 @@ sub git_get_projects_list {
 			if (!defined $path) {
 				next;
 			}
-			if (-e "$projectroot/$path/HEAD") {
+			if (-e "$projectroot/$path/HEAD" && (!$export_ok ||
+			    -e "$projectroot/$path/$export_ok")) {
 				my $pr = {
 					path => $path,
 					owner => decode("utf8", $owner, Encode::FB_DEFAULT),
-- 
1.4.2.g0ea2

^ permalink raw reply related

* Re: [PATCH] gitweb: export-ok option
From: Jakub Narebski @ 2006-09-16 19:40 UTC (permalink / raw)
  To: git
In-Reply-To: <20060916192750.GA27008@moooo.ath.cx>

Matthias Lederhofer wrote:

> Perhaps there should be another option which allows only those
> repositories to be shown which are in $projects_list.

If $projects_list is a file (and not directory), only repositories
specified there are shown.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* Re: [PATCH] gitweb: export-ok option
From: Jakub Narebski @ 2006-09-16 19:44 UTC (permalink / raw)
  To: git
In-Reply-To: <20060916192750.GA27008@moooo.ath.cx>

Matthias Lederhofer wrote:

> Similar to git-daemon checking for git-daemon-export-ok this
> introduces an optional check before showing a repository in gitweb.
> 
> I also changed the 'No such directory' error message to 'No such
> project' because the user visiting my gitweb should not know what
> directories I have in the project root directory.
> 
> undef $project; is used to prevent displaying the description.
> ---
> Perhaps there should be another option which allows only those
> repositories to be shown which are in $projects_list.

I don't know what this is for (well, except replacing 'No such directory'
error message by 'No such project'). If you want only some of repositories
to be present in gitweb, you simply use $projects_list _file_ (e.g. using
new "project_index" action to generate it) and edit it to contain only the
repositories you want to be shown in gitweb.

Unless of course the person who hosts gitweb, and the person who owns
repository are uncommunicado, and you want the power of deciding if
repository is present in gitweb or not to be placed in the hands of
repository owner. Still, gitweb must be configured for this.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* Re: [PATCH] Trivial support for cloning and fetching via ftp://.
From: Sasha Khapyorsky @ 2006-09-16 19:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7v8xkjadzv.fsf@assigned-by-dhcp.cox.net>

On 11:00 Sat 16 Sep     , Junio C Hamano wrote:
> Junio C Hamano <junkio@cox.net> writes:
> 
> > Sasha Khapyorsky <sashak@voltaire.com> writes:
> >
> >> Good. Am I need to send the patch or you will integrate it?
> >
> > Actually, I am thinking of doing this in two steps.
> >
> > The attached is the first "clean-up" step, which should be
> > obvious enough.
> >
> > And you already know what the second one that would come on top
> > of this should look like ;-).
> 
> Oops, thinko.  I sent a rolled-up one out.

Yes, and it looks good. Thanks :)

Sasha

^ permalink raw reply

* Re: [PATCH] gitweb: export-ok option
From: Matthias Lederhofer @ 2006-09-16 20:33 UTC (permalink / raw)
  To: git
In-Reply-To: <eehjtn$ipm$1@sea.gmane.org>

Jakub Narebski <jnareb@gmail.com> wrote:
> Matthias Lederhofer wrote:
> 
> > Perhaps there should be another option which allows only those
> > repositories to be shown which are in $projects_list.
> 
> If $projects_list is a file (and not directory), only repositories
> specified there are shown.

The main problem is not the list of projects. Every repository below
$project_root can be viewed using ?p=path/to/repostory.

^ permalink raw reply

* Re: [PATCH] gitweb: export-ok option
From: Junio C Hamano @ 2006-09-16 20:37 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git
In-Reply-To: <eehjtn$ipm$1@sea.gmane.org>

Jakub Narebski <jnareb@gmail.com> writes:

> Matthias Lederhofer wrote:
>
>> Perhaps there should be another option which allows only those
>> repositories to be shown which are in $projects_list.
>
> If $projects_list is a file (and not directory), only repositories
> specified there are shown.

If you can _guess_ project's name, you can go directly to
git_summary with it, and the page (or links that the page leads
to) does not check $projects_list at all, no?

I think Matthias's patch addresses that issue.

^ permalink raw reply

* [PATCH] gitweb: more support for PATH_INFO based URLs
From: Martin Waitz @ 2006-09-16 21:08 UTC (permalink / raw)
  To: git

Now three types of path based URLs are supported:
	gitweb.cgi/project.git
	gitweb.cgi/project.git/branch
	gitweb.cgi/project.git/branch/filename

The first one (show project summary) was already supported for a long time
now.  The other two are new: they show the shortlog of a branch or
the plain file contents of some file contained in the repository.

This is especially useful to support project web pages for small
projects: just create an html branch and then use an URL like
gitweb.cgi/project.git/html/index.html.

Signed-off-by: Martin Waitz <tali@admingilde.org>
---
 gitweb/gitweb.perl |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 9324d71..2789657 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -171,12 +171,7 @@ if (defined $action) {
 	}
 }
 
-our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});
-if (defined $project) {
-	$project =~ s|^/||;
-	$project =~ s|/$||;
-	$project = undef unless $project;
-}
+our $project = $cgi->param('p');
 if (defined $project) {
 	if (!validate_input($project)) {
 		die_error(undef, "Invalid project parameter");
@@ -187,7 +182,6 @@ if (defined $project) {
 	if (!(-e "$projectroot/$project/HEAD")) {
 		die_error(undef, "No such project");
 	}
-	$git_dir = "$projectroot/$project";
 }
 
 our $file_name = $cgi->param('f');
@@ -247,6 +241,32 @@ if (defined $searchtext) {
 	$searchtext = quotemeta $searchtext;
 }
 
+# now read PATH_INFO and use it as alternative to parameters
+our $path_info = $ENV{"PATH_INFO"};
+$path_info =~ s|^/||;
+$path_info =~ s|/$||;
+if (validate_input($path_info) && !defined $project) {
+	$project = $path_info;
+	while ($project && !-e "$projectroot/$project/HEAD") {
+		$project =~ s,/*[^/]*$,,;
+	}
+	if (defined $project) {
+		$project = undef unless $project;
+	}
+	if ($path_info =~ m,^$project/([^/]+)/(.+)$,) {
+		# we got "project.git/branch/filename"
+		$action    ||= "blob_plain";
+		$hash_base ||= $1;
+		$file_name ||= $2;
+	} elsif ($path_info =~ m,^$project/([^/]+)$,) {
+		# we got "project.git/branch"
+		$action ||= "shortlog";
+		$hash   ||= $1;
+	}
+}
+
+$git_dir = "$projectroot/$project";
+
 # dispatch
 my %actions = (
 	"blame" => \&git_blame2,
-- 
1.4.2.gb8b6b

-- 
Martin Waitz

^ permalink raw reply related

* [PATCH] gitweb: fix uninitialized variable warning.
From: Martin Waitz @ 2006-09-16 21:09 UTC (permalink / raw)
  To: git

Perl spit out a varning when "blob" or "blob_plain" actions were
used without a $hash parameter.

Signed-off-by: Martin Waitz <tali@admingilde.org>
---
 gitweb/gitweb.perl |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 2789657..ee561c6 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2380,11 +2380,7 @@ sub git_heads {
 }
 
 sub git_blob_plain {
-	# blobs defined by non-textual hash id's can be cached
 	my $expires;
-	if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
-		$expires = "+1d";
-	}
 
 	if (!defined $hash) {
 		if (defined $file_name) {
@@ -2394,7 +2390,11 @@ sub git_blob_plain {
 		} else {
 			die_error(undef, "No file name defined");
 		}
+	} elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
+		# blobs defined by non-textual hash id's can be cached
+		$expires = "+1d";
 	}
+
 	my $type = shift;
 	open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
 		or die_error(undef, "Couldn't cat $file_name, $hash");
@@ -2422,11 +2422,7 @@ sub git_blob_plain {
 }
 
 sub git_blob {
-	# blobs defined by non-textual hash id's can be cached
 	my $expires;
-	if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
-		$expires = "+1d";
-	}
 
 	if (!defined $hash) {
 		if (defined $file_name) {
@@ -2436,7 +2432,11 @@ sub git_blob {
 		} else {
 			die_error(undef, "No file name defined");
 		}
+	} elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
+		# blobs defined by non-textual hash id's can be cached
+		$expires = "+1d";
 	}
+
 	my $have_blame = gitweb_check_feature('blame');
 	open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
 		or die_error(undef, "Couldn't cat $file_name, $hash");
-- 
1.4.2.gb8b6b

-- 
Martin Waitz

^ permalink raw reply related


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