Git development
 help / color / mirror / Atom feed
* Re: [PATCH] gitweb: handle non UTF-8 text
From: Alexandre Julliard @ 2007-06-03 18:41 UTC (permalink / raw)
  To: Jakub Narebski
  Cc: Junio C Hamano, Martin Koegler, Petr Baudis, git, Martin Langhoff,
	Martyn Smith, Robin Rosenberg
In-Reply-To: <200706031742.45216.jnareb@gmail.com>

Jakub Narebski <jnareb@gmail.com> writes:

> Alexandre, I hope that the patch attached would solve your problem.

Yes, it works fine for me, thanks!

-- 
Alexandre Julliard
julliard@winehq.org

^ permalink raw reply

* Re: [PATCH] Add git-filter-branch
From: Steven Grimm @ 2007-06-03 18:36 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: Johannes Schindelin, git
In-Reply-To: <200706031228.58779.jnareb@gmail.com>

Jakub Narebski wrote:
> By the way, why did you change name to git-filter-branch, instead of
> leaving it [almost] as is, i.e. git-rewritehist. Or if you wanted to
> emphasize that it rewrites only one branch at a time, git-rewrite-branch?
>   

One argument against the name change is that one could easily imagine 
this tool being extended in the future to filter all branches rather 
than just one. For example, the "get rid of copyrighted file X in my 
repository" use case is a bit of a pain right now using 
cg-admin-rewritehist if the file was introduced early in the history of 
a large repo; in that scenario you want to be able to say, "filter this 
file out of my entire repo" without particularly caring which branches 
it appeared in (and without losing any of the branch structure in your 
history.)

-Steve

^ permalink raw reply

* Re: gitweb on shared hosting
From: Jakub Narebski @ 2007-06-03 18:36 UTC (permalink / raw)
  To: git
In-Reply-To: <200706021953.09942.dev.list@mircea.bardac.net>

Mircea Bardac wrote:

> It is also very strange to have README/"How to configure gitweb for your local 
> system" saying "You can specify the following configuration variables when 
> buiding GIT". That means I have to rebuild GIT (actually, only 
> gitweb/gitweb.cgi) to configure gitweb => I need to download the sources by 
> hand instead of using the already installed gitweb on my system (the one 
> which came with the git package).

First, it is when building gitweb/gitweb.cgi from gitweb/gitweb.perl, but
in practice that is just filling configuration in a few places. See the
places in the source, and later you can edit gitweb.cgi by hand.

> Is there any strong reason to have configuration at build-time at all? It 
> would be a lot easier IMO to have it *just* by config files. I'm saying this 
> because most of the install process is manual anyway (copying/moving files).

You can override configuration using config file (with exception of name of
config file), and put [almost] all configuration in config file.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* [PATCH] pack-check: Sort entries by pack offset before unpacking them.
From: Alexandre Julliard @ 2007-06-03 18:21 UTC (permalink / raw)
  To: git

Because of the way objects are sorted in a pack, unpacking them in
disk order is much more efficient than random access. Tests on the
Wine repository show a gain in pack validation time of about 35%.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
---
 pack-check.c |   47 +++++++++++++++++++++++++++++++++++------------
 1 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/pack-check.c b/pack-check.c
index 3623c71..d7dd62b 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -1,6 +1,23 @@
 #include "cache.h"
 #include "pack.h"
 
+struct idx_entry
+{
+	const unsigned char *sha1;
+	off_t                offset;
+};
+
+static int compare_entries(const void *e1, const void *e2)
+{
+	const struct idx_entry *entry1 = e1;
+	const struct idx_entry *entry2 = e2;
+	if (entry1->offset < entry2->offset)
+		return -1;
+	if (entry1->offset > entry2->offset)
+		return 1;
+	return 0;
+}
+
 static int verify_packfile(struct packed_git *p,
 		struct pack_window **w_curs)
 {
@@ -11,6 +28,7 @@ static int verify_packfile(struct packed_git *p,
 	off_t offset = 0, pack_sig = p->pack_size - 20;
 	uint32_t nr_objects, i;
 	int err;
+	struct idx_entry *entries;
 
 	/* Note that the pack header checks are actually performed by
 	 * use_pack when it first opens the pack file.  If anything
@@ -41,33 +59,38 @@ static int verify_packfile(struct packed_git *p,
 	 * we do not do scan-streaming check on the pack file.
 	 */
 	nr_objects = p->num_objects;
+	entries = xmalloc(nr_objects * sizeof(*entries));
+	/* first sort entries by pack offset, since unpacking them is more efficient that way */
+	for (i = 0; i < nr_objects; i++) {
+		entries[i].sha1 = nth_packed_object_sha1(p, i);
+		if (!entries[i].sha1)
+			die("internal error pack-check nth-packed-object");
+		entries[i].offset = find_pack_entry_one(entries[i].sha1, p);
+		if (!entries[i].offset)
+			die("internal error pack-check find-pack-entry-one");
+	}
+	qsort(entries, nr_objects, sizeof(*entries), compare_entries);
+
 	for (i = 0, err = 0; i < nr_objects; i++) {
-		const unsigned char *sha1;
 		void *data;
 		enum object_type type;
 		unsigned long size;
-		off_t offset;
 
-		sha1 = nth_packed_object_sha1(p, i);
-		if (!sha1)
-			die("internal error pack-check nth-packed-object");
-		offset = find_pack_entry_one(sha1, p);
-		if (!offset)
-			die("internal error pack-check find-pack-entry-one");
-		data = unpack_entry(p, offset, &type, &size);
+		data = unpack_entry(p, entries[i].offset, &type, &size);
 		if (!data) {
 			err = error("cannot unpack %s from %s",
-				    sha1_to_hex(sha1), p->pack_name);
+				    sha1_to_hex(entries[i].sha1), p->pack_name);
 			continue;
 		}
-		if (check_sha1_signature(sha1, data, size, typename(type))) {
+		if (check_sha1_signature(entries[i].sha1, data, size, typename(type))) {
 			err = error("packed %s from %s is corrupt",
-				    sha1_to_hex(sha1), p->pack_name);
+				    sha1_to_hex(entries[i].sha1), p->pack_name);
 			free(data);
 			continue;
 		}
 		free(data);
 	}
+	free(entries);
 
 	return err;
 }
-- 
1.5.2.156.gb09c8

-- 
Alexandre Julliard
julliard@winehq.org

^ permalink raw reply related

* Re: [PATCH] gitweb: handle non UTF-8 text
From: Jakub Narebski @ 2007-06-03 15:42 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Martin Koegler, Petr Baudis, git, Martin Langhoff, Martyn Smith,
	Robin Rosenberg, Alexandre Julliard
In-Reply-To: <7vvee6nguh.fsf@assigned-by-dhcp.cox.net>

Alexandre, I hope that the patch attached would solve your problem.

Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> On Tue, 29 May 2007, Martin Koegler wrote:
>> ...
>>> But I agree, that there should be the possibilty to choose the
>>> fallback encoding.
>>
>> I think for the beginning it would be enough to have
>>
>>   # assume this charset if line contains non-UTF-8 characters
>>   our $fallback_encoding = "latin1";

Added this, with more elaborate comment, just before %feature hash.

>> or something like that (perhaps different wording in the comment,
>> perhaps different name of the variable) in the gitweb.perl for your
>> idea to be accepted.
>>
>> That, and using to_utf8 (as before e3ad95a8) and not my_decode_utf8
>> as subroutine name. If only it would be possible to avoid I think
>> quote costly "eval {....}" invocation...
> 
> Except that I had an impression that block form of "eval" (as
> opposed to "parse and evaluate string" kind) was not costly at
> all.

I have checked the time it took to run the gitweb test (t9500),
and the time to run (user+sys) increased about 1% after this patch,
which is even within range of error I think.
 
> Please make it so.

I have changed the name from my_decode_utf8 to the name used for thin
wrapper before commit e3ad95a8 "gitweb: use decode_utf8 directly", namely
to_utf8, and put it in the place where old to_utf8 subroutine was.

Instead of bit hackish "return $res || decode('latin1', $str);" use
"if (defined $res) { ... } else { ... }"; it avoids calling decode()
unnecessary for '' and '0' strings, which are also false, but do not mean
that decode_utf8 failed.

It uses explicit constant names, Encode::FB_CROAK instead of 1, and
Encode::FB_DEFAULT instead of default undef/0.

It adds very, very basic test: it does check _only_ if there are any
errors or warning which would go to web server log; it does not check
if the output is correct. It uses helper files from other i18n tests.

Added comments.


Still the main change is by Martin Koegler and he should be author of
this commit, I think. I have added S-o-b: by me.

-- >8 --
From: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Subject: [PATCH] gitweb: Handle non UTF-8 text better

gitweb assumes that everything is in UTF-8. If a text contains invalid
UTF-8 character sequences, the text must be in a different encoding.

This commit introduces $fallback_encoding which would be used as input
encoding if gitweb encounters text with is not valid UTF-8.

Add basic test for this in t/t9500-gitweb-standalone-no-errors.sh

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl                     |   41 ++++++++++++++++++++++++-------
 t/t9500-gitweb-standalone-no-errors.sh |   28 +++++++++++++++++++++
 2 files changed, 59 insertions(+), 10 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index c3921cb..e92596c 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -94,6 +94,13 @@ our $default_text_plain_charset  = undef;
 # (relative to the current git repository)
 our $mimetypes_file = undef;
 
+# assume this charset if line contains non-UTF-8 characters;
+# it should be valid encoding (see Encoding::Supported(3pm) for list),
+# for which encoding all byte sequences are valid, for example
+# 'iso-8859-1' aka 'latin1' (it is decoded without checking, so it
+# could be even 'utf-8' for the old behavior)
+our $fallback_encoding = 'latin1';
+
 # You define site-wide feature defaults here; override them with
 # $GITWEB_CONFIG as necessary.
 our %feature = (
@@ -602,6 +609,20 @@ sub validate_refname {
 	return $input;
 }
 
+# decode sequences of octets in utf8 into Perl's internal form,
+# which is utf-8 with utf8 flag set if needed.  gitweb writes out
+# in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
+sub to_utf8 {
+	my $str = shift;
+	my $res;
+	eval { $res = decode_utf8($str, Encode::FB_CROAK); };
+	if (defined $res) {
+		return $res;
+	} else {
+		return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
+	}
+}
+
 # quote unsafe chars, but keep the slash, even when it's not
 # correct, but quoted slashes look too horrible in bookmarks
 sub esc_param {
@@ -626,7 +647,7 @@ sub esc_html ($;%) {
 	my $str = shift;
 	my %opts = @_;
 
-	$str = decode_utf8($str);
+	$str = to_utf8($str);
 	$str = $cgi->escapeHTML($str);
 	if ($opts{'-nbsp'}) {
 		$str =~ s/ /&nbsp;/g;
@@ -640,7 +661,7 @@ sub esc_path {
 	my $str = shift;
 	my %opts = @_;
 
-	$str = decode_utf8($str);
+	$str = to_utf8($str);
 	$str = $cgi->escapeHTML($str);
 	if ($opts{'-nbsp'}) {
 		$str =~ s/ /&nbsp;/g;
@@ -925,7 +946,7 @@ sub format_subject_html {
 
 	if (length($short) < length($long)) {
 		return $cgi->a({-href => $href, -class => "list subject",
-		                -title => decode_utf8($long)},
+		                -title => to_utf8($long)},
 		       esc_html($short) . $extra);
 	} else {
 		return $cgi->a({-href => $href, -class => "list subject"},
@@ -1239,7 +1260,7 @@ sub git_get_projects_list {
 			if (check_export_ok("$projectroot/$path")) {
 				my $pr = {
 					path => $path,
-					owner => decode_utf8($owner),
+					owner => to_utf8($owner),
 				};
 				push @list, $pr;
 				(my $forks_path = $path) =~ s/\.git$//;
@@ -1269,7 +1290,7 @@ sub git_get_project_owner {
 			$pr = unescape($pr);
 			$ow = unescape($ow);
 			if ($pr eq $project) {
-				$owner = decode_utf8($ow);
+				$owner = to_utf8($ow);
 				last;
 			}
 		}
@@ -1759,7 +1780,7 @@ sub get_file_owner {
 	}
 	my $owner = $gcos;
 	$owner =~ s/[,;].*$//;
-	return decode_utf8($owner);
+	return to_utf8($owner);
 }
 
 ## ......................................................................
@@ -1842,7 +1863,7 @@ sub git_header_html {
 
 	my $title = "$site_name";
 	if (defined $project) {
-		$title .= " - " . decode_utf8($project);
+		$title .= " - " . to_utf8($project);
 		if (defined $action) {
 			$title .= "/$action";
 			if (defined $file_name) {
@@ -2116,7 +2137,7 @@ sub git_print_page_path {
 
 	print "<div class=\"page_path\">";
 	print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
-	              -title => 'tree root'}, decode_utf8("[$project]"));
+	              -title => 'tree root'}, to_utf8("[$project]"));
 	print " / ";
 	if (defined $name) {
 		my @dirname = split '/', $name;
@@ -2936,7 +2957,7 @@ sub git_project_list_body {
 		($pr->{'age'}, $pr->{'age_string'}) = @aa;
 		if (!defined $pr->{'descr'}) {
 			my $descr = git_get_project_description($pr->{'path'}) || "";
-			$pr->{'descr_long'} = decode_utf8($descr);
+			$pr->{'descr_long'} = to_utf8($descr);
 			$pr->{'descr'} = chop_str($descr, 25, 5);
 		}
 		if (!defined $pr->{'owner'}) {
@@ -3981,7 +4002,7 @@ sub git_snapshot {
 	my $git = git_cmd_str();
 	my $name = $project;
 	$name =~ s/\047/\047\\\047\047/g;
-	my $filename = decode_utf8(basename($project));
+	my $filename = to_utf8(basename($project));
 	my $cmd;
 	if ($suffix eq 'zip') {
 		$filename .= "-$hash.$suffix";
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index b92ab63..44ae503 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -487,4 +487,32 @@ test_expect_success \
 	'gitweb_run "p=.git;a=atom"'
 test_debug 'cat gitweb.log'
 
+# ----------------------------------------------------------------------
+# encoding/decoding
+
+test_expect_success \
+	'encode(commit): utf8' \
+	'. ../t3901-utf8.txt &&
+	 echo "UTF-8" >> file &&
+	 git add file &&
+	 git commit -F ../t3900/1-UTF-8.txt &&
+	 gitweb_run "p=.git;a=commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'encode(commit): iso-8859-1' \
+	'. ../t3901-8859-1.txt &&
+	 echo "ISO-8859-1" >> file &&
+	 git add file &&
+	 git config i18n.commitencoding ISO-8859-1 &&
+	 git commit -F ../t3900/ISO-8859-1.txt &&
+	 git config --unset i18n.commitencoding &&
+	 gitweb_run "p=.git;a=commit"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+	'encode(log): utf-8 and iso-8859-1' \
+	'gitweb_run "p=.git;a=log"'
+test_debug 'cat gitweb.log'
+
 test_done
-- 
1.5.2

^ permalink raw reply related

* Re: [PATCH] Add git-filter-branch
From: Jakub Narebski @ 2007-06-03 10:28 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0706030147520.4046@racer.site>

On Sun, 3 Jun 2007, Johannes Schindelin wrote:
> On Sun, 3 Jun 2007, Jakub Narebski wrote:
>> Johannes Schindelin wrote:
>> 
>>> This script is derived from Pasky's cg-admin-rewritehist.
>>> 
>>> In fact, it _is_ the same script, minimally adapted to work without cogito.
>>> It _should_ be able to perform the same tasks, even if only relying on
>>> core-git programs.
>>> 
>>> All the work is Pasky's, just the adaption is mine.
>> 
>> I was thinking about rewriting cg-adin-rewritehist as git-rewritehist
>> using Perl (IIRC it needs bash, not only POSIX shell), and make it
>> use git-fast-import.

By the way, why did you change name to git-filter-branch, instead of
leaving it [almost] as is, i.e. git-rewritehist. Or if you wanted to
emphasize that it rewrites only one branch at a time, git-rewrite-branch?

Note that history (branch) gets rewritten also in absence of filters,
if there are any grafts in place. But I might be mistaken.

> First, it does not need Perl.
> 
> Second, it does not even need bash.

If I remember correctly (but I can be wrong here) Pasky said that he had
to use arrays in cg-admin-rewritehist. Because introducing dependency on
bash would be bad, that was the cause of thought to rewrite it in Perl
(which we depend on anyway). 

See below.

> At least that is what I tried to make sure. I replaced the only instance 
> of a bashim I was aware, namely the arrayism of $unchanged. It can be a 
> string just as well, as we are only storing object names in it.

I'm sorry, I haven't reviewed your patch carefully enough, it seems like.
If you can translate cg-admin-rewritehist to POSIX shell, more power
to you.

                          -- " --

Few notes of lesser importance (meaning they can go into subsequent
commits).

1. Documentation: Cogito had documentation together with the command
   described, similarly to Perl POD, or LaTeX doc package + DocStrip,
   etc. It has IIRC rules in Makefile to extract documentation.

   In git we have documentation in separate files. The commands
   themselves have only usage, and sometimes long usage embedded.
   It would be nice of git-filter-branch / git-rewrite-branch also
   followed this convention.

2. Using fast-import.

   >> +# Note that since this operation is extensively I/O expensive, it might
   >> +# be a good idea to do it off-disk, e.g. on tmpfs. Reportedly the speedup
   >> +# is very noticeable.

   Would it be possible to use git-fast-import to reduce I/O in this
   command? Cogito didn't use it because it is quite new, but there
   is no reason to not to use it now, I think.

-- 
Jakub Narebski
Poland

^ permalink raw reply

* Re: [RFC] git integrated bugtracking
From: david @ 2007-06-03 17:35 UTC (permalink / raw)
  To: Pierre Habouzit; +Cc: Johan Herland, git, Michael Poole
In-Reply-To: <20070603160736.GC30347@artemis>

On Sun, 3 Jun 2007, Pierre Habouzit wrote:

> On Sun, Jun 03, 2007 at 05:44:58PM +0200, Matthieu Moy wrote:
>> Pierre Habouzit <madcoder@debian.org> writes:
>>
>>>   Yeah, now that I read that thread, well yeah, I think notes are a hell
>>> of a good concept for my ideas. I mean, a bug report would be basically
>>> a collection of notes:
>>>   * the bug has been found at this commit ;
>>>   * the bug has been not-found at this commit ;
>>>   * this commit is a fix for that bug ;
>>
>> That's my feeling too. "Commiting" bug information in the tree is only
>> half of a good idea. You want to be able to say, after the fact, "This
>> commit had bug XYZ". OTOH, the idea (followed by bugs everywhere) that
>> merging a branch would automatically close bugs fixed by this branch
>> is a really cool thing.
>
>  That would work with notes, as while merging you'll get the notes of
> the commit in your branch, *and* the note about the fixing patch. So
> there is no loss of "concept" here. In fact that was the thing that I
> looked for. Notes are good. They just may not be enough to write an
> in-git bugtracking tool, as a bug needs the "notes collection" concepts,
> and maybe a few other.

how would you identify bugs in such a way that they will match up when you 
merge different trees?

if you can manage to do this it sounds like a great idea. but I'm not 
seeing a good way to do it at the moment. the answer may be a combination 
of a number of factors.

1. bug number doesn't work well in a distributed environment

2. something based on indentifying the cause of the bug (commit id + file 
+ line????) will only work after you know the real cause of the bug

3. description is worthless, too many ways to describe things that have 
the same underlying cause

David Lang

^ permalink raw reply

* Re: [RFC PATCH] Add git quick reference
From: J. Bruce Fields @ 2007-06-03 17:15 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: git
In-Reply-To: <20070602182423.GC19952@diku.dk>

On Sat, Jun 02, 2007 at 08:24:23PM +0200, Jonas Fonseca wrote:
> It attempts to list some of the most commonly used commands, which should
> give new users an idea of how to get started.
> 
> Available both as a manpage (generated via a script) and HTML page.

We have a "git quick start" here:

	http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#git-quick-start

and there's one on the wiki:

	http://git.or.cz/gitwiki/QuickStart

I think the one in the manual tries to follow the organization of the
manual more closely.

I haven't tried to compare those two recently, or to compare yours to
either of them.  If you could compare and suggest any improvements,
that'd be helpful.

I like your name better ("quick reference" as opposed to "quick start").

Having it as a man page may be a good idea too.  I'd like to keep a copy
in the manual as well, though, so we'd have to include from some common
file.

--b.

^ permalink raw reply

* Re: [RFC] GIT_WORK_TREE
From: Sergio @ 2007-06-03 16:02 UTC (permalink / raw)
  To: git
In-Reply-To: <20070603144401.GA9518@moooo.ath.cx>

Matthias Lederhofer <matled <at> gmx.net> writes:
 
> This series introduces the GIT_WORK_TREE environment variable (and
> core.worktree config option) to specify the working tree that should
> be used with the repository (not for repositories found as .git
> directory).  This allows to separate the repository and working tree.

Hi,

a question regarding GIT_WORK_TREE and (possibly) a suggestion...

If I am not wrong, with this we detach the WT from the REPO by letting git know
our working tree if the working tree does not include a repo (.git) directory.
And this is done either:
- by setting the GIT_WORK_TREE environment variable whenever needed
- by passing the --work-tree parameter to git when needed
- by setting the core.worktree config option in the git repo, so that the
repository knows where its default work tree is...

Is this correct? or am I missing some other ways?

Would it make sense to make the _WT_ know where its repo is?

I.e. having something like a .git-repo file a the top dir of a WT, so that when
git is invoked within the WT it can scan up the WT until it finds the .git-repo
file and automatically decide that GIT_WORK_TREE is at the dir containing that
.git-repo file and that GIT_DIR is at the file pointed by that .git-repo?

Thanks,

Sergio

^ permalink raw reply

* Re: [RFC] git integrated bugtracking
From: Yann Dirson @ 2007-06-03 17:10 UTC (permalink / raw)
  To: Johan Herland, git, Michael Poole
In-Reply-To: <20070603151921.GB30347@artemis>

On Sun, Jun 03, 2007 at 05:19:21PM +0200, Pierre Habouzit wrote:
>   Another think that notes do not address are another operation we
> usually do on bugs: merge (or duplicates). There is a think I hate in
> bugzilla and love in debbugs, it's that duplicate bugs are closed in the
> former, and merged in the latter. When two bugs are the same, their
> history are often *both* valuable, and you really don't want to lose one
> half, you want to merge them. And you also want the option to "unmerge"
> them, but for that the better option is to have the ability to duplicate
> a bug (aka debbugs cloning).

I can't wait for visualising the history of bugreports in gitk, along
with duplicates/forks and merges :)

>   Anyways it's just gossip, but maybe someone will have a brilliant
> ideas, so I'm just throwing my thoughts into this mail :)

/me wishes all gossip would be as productive as this one :)

Best regards,
-- 
Yann

^ permalink raw reply

* Re: [RFC] git integrated bugtracking
From: Pierre Habouzit @ 2007-06-03 16:07 UTC (permalink / raw)
  To: Johan Herland, git, Michael Poole
In-Reply-To: <vpq1wgtnith.fsf@bauges.imag.fr>

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

On Sun, Jun 03, 2007 at 05:44:58PM +0200, Matthieu Moy wrote:
> Pierre Habouzit <madcoder@debian.org> writes:
> 
> >   Yeah, now that I read that thread, well yeah, I think notes are a hell
> > of a good concept for my ideas. I mean, a bug report would be basically
> > a collection of notes:
> >   * the bug has been found at this commit ;
> >   * the bug has been not-found at this commit ;
> >   * this commit is a fix for that bug ;
> 
> That's my feeling too. "Commiting" bug information in the tree is only
> half of a good idea. You want to be able to say, after the fact, "This
> commit had bug XYZ". OTOH, the idea (followed by bugs everywhere) that
> merging a branch would automatically close bugs fixed by this branch
> is a really cool thing.

  That would work with notes, as while merging you'll get the notes of
the commit in your branch, *and* the note about the fixing patch. So
there is no loss of "concept" here. In fact that was the thing that I
looked for. Notes are good. They just may not be enough to write an
in-git bugtracking tool, as a bug needs the "notes collection" concepts,
and maybe a few other.

> The kind of information you're mentionning above can be a great
> starting point for "bisect". I can even imagine a kind of distributed
> bisect, where several users could give their "bad commits" for the
> same bug.

  Heh yes. Sometimes it's more complex than that as bugs can come back
(regressions) or be the result of many commits (like the cases that suck
with bisect). For a complex bug it's more a set of [found..notfound[
intervals. Though this indeed is very valuable information, and the
distributed component thing *is* great.

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

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

^ permalink raw reply

* (unknown)
From: Randal L. Schwartz @ 2007-06-03 15:30 UTC (permalink / raw)
  To: git

>From 8948e5c81bf39ca7a8118746e4ca60b3b1566efa Mon Sep 17 00:00:00 2001
From: Randal L. Schwartz <merlyn@stonehenge.com>
Date: Sun, 3 Jun 2007 08:27:52 -0700
Subject: [PATCH] Add test-sha1 to .gitignore.

---
 .gitignore |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index 15aed70..8e75c99 100644
--- a/.gitignore
+++ b/.gitignore
@@ -151,6 +151,7 @@ test-delta
 test-dump-cache-tree
 test-genrandom
 test-match-trees
+test-sha1
 common-cmds.h
 *.tar.gz
 *.dsc
-- 
1.5.2.1.111.gc94b

^ permalink raw reply related

* Re: [RFC] git integrated bugtracking
From: Matthieu Moy @ 2007-06-03 15:44 UTC (permalink / raw)
  To: Johan Herland; +Cc: git, Michael Poole
In-Reply-To: <20070603151921.GB30347@artemis>

Pierre Habouzit <madcoder@debian.org> writes:

>   Yeah, now that I read that thread, well yeah, I think notes are a hell
> of a good concept for my ideas. I mean, a bug report would be basically
> a collection of notes:
>   * the bug has been found at this commit ;
>   * the bug has been not-found at this commit ;
>   * this commit is a fix for that bug ;

That's my feeling too. "Commiting" bug information in the tree is only
half of a good idea. You want to be able to say, after the fact, "This
commit had bug XYZ". OTOH, the idea (followed by bugs everywhere) that
merging a branch would automatically close bugs fixed by this branch
is a really cool thing.

The kind of information you're mentionning above can be a great
starting point for "bisect". I can even imagine a kind of distributed
bisect, where several users could give their "bad commits" for the
same bug.

-- 
Matthieu

^ permalink raw reply

* Re: gitweb on shared hosting
From: Martin Koegler @ 2007-06-03 15:35 UTC (permalink / raw)
  To: dev.list; +Cc: git

> I don't know if this is possible or not, but I'm trying with no results.
> 
> Is it possible to install gitweb on a shared hosting system, with no root 
> access. Reading the INSTALL document reveals only information for 
> configuration on build-time/install as root.

It is possible to install gitweb without root access, if you have:
1) A system to compile C programs for the hosting system
2) A directory to copy the binaries to on the hosting system. I would not make it accessible via the webserver.
3) A directory published by the webserver for static files
4) A directory which supports running perl cgis

If the requirements are met, do the following:
a) Extract git sources
b) Change in the Makefile PREFIX to the directories for the binaries
c) run make
d) If you compile on the hosting system, simple run make install. If
not, create a directory with the same patch as the binary directory on
the hosting system, run make install and copy the content of binary
directory to the hosting system (preserving the x-bits).
e) Copy gitweb/git-favicon.png, gitweb/git-logo.png and gitweb/gitweb.css onto your webserver.
f) Install gitweb/gitweb.cgi as perl CGI program. gitweb.cgi needs some configuration. You can
specify them either in a seperate configuration file or change the default settings in gitweb.cgi.

You should check the following options:
our $GIT = "/homes/user/bin/git"; #  path to the git binary 
our $projectroot = "/pub/git"; # path to the directoriy containing all git repositories
our @stylesheets = ("gitweb.css"); # URL to stylesheet
our $logo = "git-logo.png"; # URL to image
our $favicon = "git-favicon.png"; # URL to image

If the webserver has read (and execute for the binaries) rights on all
files (including the repositories), gitweb should work.

mfg Martin Kögler

^ permalink raw reply

* Re: [RFC] git integrated bugtracking
From: Pierre Habouzit @ 2007-06-03 15:19 UTC (permalink / raw)
  To: Johan Herland; +Cc: git, Michael Poole
In-Reply-To: <200706031548.30111.johan@herland.net>

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

On Sun, Jun 03, 2007 at 03:48:29PM +0200, Johan Herland wrote:
> On Sunday 03 June 2007, Pierre Habouzit wrote:
> > On Sun, Jun 03, 2007 at 08:59:18AM -0400, Michael Poole wrote:
> > > Pierre Habouzit writes:
> > >
> > > >   The other problem I see is that at the time a bug gets reported, the
> > > > user knows it's found at a commit say 'X'. But it could in fact have
> > > > been generated at a commit Y, with this pattern:
> > > >
> > > >   --o---o---Y---o---o---o---o---X---o---o--> master
> > > >                      \
> > > >                       o---o---o---o---o---o--> branch B
> > > 
> > > Mainly for that reason, I would suggest having it outside the code
> > > base's namespace: probably a different root in the same $GIT_DIR, but
> > > I can see people wanting to have a separate $GIT_DIR.  If the database
> > > tracks bugs by what commit(s) introduce or expose the bug -- at least
> > > once that is known -- then you get nearly free tracking of which
> > > branches have the bug without having to check out largely redundant
> > > trees.
> > 
> >   Sure, but if it's completely out-of-tree, then cloning a repository
> > don't allow you to get the bug databases with it for free. I mean it'd
> > be great to have it somehow linked to the repository, but also I agree
> > that not everybody wants to clone the whole bugs databases. So maybe it
> > should just be in another shadow branch that annotates the devel ones.
> > Hmmm I definitely need to read the git-note thread...
> 
> I guess I'm the one responsible for starting that git-note thread...
> 
> For the moment, I'm busy implementing some concepts that came out of that 
> discussion (refactoring tag objects and building some infrastructure needed 
> to support notes without the drawbacks present in my first version).
> 
> Hopefully I'll have a proof-of-concept ready before too long. In the 
> meantime I'll be happy to answer questions you might have.
> 
> Regarding the notes themselves, I thought about possibly using them as a 
> link between the repo and the bug tracker, with some glue code in between 
> for making the connections. I haven't thought about integrating them more 
> deeply into a bug tracker, but it might be worth thinking along those 
> lines, especially for the kind of system you're proposing.

  Yeah, now that I read that thread, well yeah, I think notes are a hell
of a good concept for my ideas. I mean, a bug report would be basically
a collection of notes:
  * the bug has been found at this commit ;
  * the bug has been not-found at this commit ;
  * this commit is a fix for that bug ;
  * this commit enhance features for that wish and so on.
Some other bits are more followup comments and are disconnected to
commits, but could be attached to the "bug object" whatever would be
used for bugs, the whole concept is blurry anyways, we're just
discussing ideas :)

  Though, for a good bug tracking system, you need to be able to answer
some kind of questions fast enough:
  * list bugs that affect a given stage of the repository
    (tag/branch/commit/...) ;
  * be able to trace history of a given bug (yes, it's fairly obvious,
    but unlike many other bug tracking systems, for us it would not be
    contiguous, so it's not necessarily a O(1) operation) ;

  Other things nice to have is textual search, git-grep can help of
course, but that's an operation you do often with a bug tracking system,
and you expect it to be faster than git-grep is (though maybe an
optionnal index can be built around the notes for that purpose and not
be versionned ?).

  Another think that notes do not address are another operation we
usually do on bugs: merge (or duplicates). There is a think I hate in
bugzilla and love in debbugs, it's that duplicate bugs are closed in the
former, and merged in the latter. When two bugs are the same, their
history are often *both* valuable, and you really don't want to lose one
half, you want to merge them. And you also want the option to "unmerge"
them, but for that the better option is to have the ability to duplicate
a bug (aka debbugs cloning).

  Anyways it's just gossip, but maybe someone will have a brilliant
ideas, so I'm just throwing my thoughts into this mail :)

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

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

^ permalink raw reply

* Re: [RFC] GIT_WORK_TREE
From: Matthias Lederhofer @ 2007-06-03 14:51 UTC (permalink / raw)
  To: Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <20070603144816.GE20061@moooo.ath.cx>

Subject should have been:
[PATCH] use new semantics of is_bare/inside_git_dir/inside_work_tree

^ permalink raw reply

* [PATCH 7/7] test GIT_WORK_TREE
From: Matthias Lederhofer @ 2007-06-03 14:49 UTC (permalink / raw)
  To: Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <20070603144401.GA9518@moooo.ath.cx>

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 t/t1501-worktree.sh |  119 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 119 insertions(+), 0 deletions(-)
 create mode 100755 t/t1501-worktree.sh

diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
new file mode 100755
index 0000000..d9d9e4a
--- /dev/null
+++ b/t/t1501-worktree.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+test_description='test separate work tree'
+. ./test-lib.sh
+
+test_rev_parse() {
+	name=$1
+	shift
+
+	test_expect_success "$name: is-bare-repository" \
+	"test '$1' = \"\$(git rev-parse --is-bare-repository)\""
+	shift
+	[ $# -eq 0 ] && return
+
+	test_expect_success "$name: is-inside-git-dir" \
+	"test '$1' = \"\$(git rev-parse --is-inside-git-dir)\""
+	shift
+	[ $# -eq 0 ] && return
+
+	test_expect_success "$name: is-inside-work-tree" \
+	"test '$1' = \"\$(git rev-parse --is-inside-work-tree)\""
+	shift
+	[ $# -eq 0 ] && return
+
+	test_expect_success "$name: prefix" \
+	"test '$1' = \"\$(git rev-parse --show-prefix)\""
+	shift
+	[ $# -eq 0 ] && return
+}
+
+mkdir -p work/sub/dir || exit 1
+
+say "fallback work tree (name ending in .git)"
+cd work || exit 1
+export GIT_DIR=../.git
+export GIT_CONFIG=$GIT_DIR/config
+unset GIT_WORK_TREE
+git config core.bare true
+test_rev_parse 'core.bare = true'    true  false false
+git config --unset core.bare
+test_rev_parse 'core.bare undefined' false false true
+git config core.bare false
+test_rev_parse 'core.bare = false'   false false true ''
+cd .. || exit 1
+
+mv .git repo.git || exit 1
+
+say "fallback work tree (name ending in repo.git)"
+cd work || exit 1
+export GIT_DIR=../repo.git
+export GIT_CONFIG=$GIT_DIR/config
+unset GIT_WORK_TREE
+git config core.bare true
+test_rev_parse 'core.bare = true'    true  false false
+git config --unset core.bare
+test_rev_parse 'core.bare undefined' true  false false
+git config core.bare false
+test_rev_parse 'core.bare = false'   false false true ''
+cd .. || exit 1
+
+say "core.worktree = relative path"
+export GIT_DIR=repo.git
+export GIT_CONFIG=$GIT_DIR/config
+unset GIT_WORK_TREE
+git config core.worktree ../work
+test_rev_parse 'outside'      false false false
+cd work || exit 1
+export GIT_DIR=../repo.git
+export GIT_CONFIG=$GIT_DIR/config
+test_rev_parse 'inside'       false false true ''
+cd sub/dir || exit 1
+export GIT_DIR=../../../repo.git
+export GIT_CONFIG=$GIT_DIR/config
+test_rev_parse 'subdirectory' false false true sub/dir/
+cd ../../.. || exit 1
+
+say "core.worktree = absolute path"
+export GIT_DIR=$(pwd)/repo.git
+export GIT_CONFIG=$GIT_DIR/config
+git config core.worktree "$(pwd)/work"
+test_rev_parse 'outside'      false false false
+cd work || exit 1
+test_rev_parse 'inside'       false false true ''
+cd sub/dir || exit 1
+test_rev_parse 'subdirectory' false false true sub/dir/
+cd ../../.. || exit 1
+
+say "GIT_WORK_TREE=relative path (override core.worktree)"
+export GIT_DIR=$(pwd)/repo.git
+export GIT_CONFIG=$GIT_DIR/config
+git config core.worktree non-existent
+export GIT_WORK_TREE=work
+test_rev_parse 'outside'      false false false
+cd work || exit 1
+export GIT_WORK_TREE=.
+test_rev_parse 'inside'       false false true ''
+cd sub/dir || exit 1
+export GIT_WORK_TREE=../..
+test_rev_parse 'subdirectory' false false true sub/dir/
+cd ../../.. || exit 1
+
+mv work repo.git/work
+
+say "GIT_WORK_TREE=absolute path, work tree below git dir"
+export GIT_DIR=$(pwd)/repo.git
+export GIT_CONFIG=$GIT_DIR/config
+export GIT_WORK_TREE=$(pwd)/repo.git/work
+test_rev_parse 'outside'              false false false
+cd repo.git || exit 1
+test_rev_parse 'in repo.git'              false true  false
+cd objects || exit 1
+test_rev_parse 'in repo.git/objects'      false true  false
+cd ../work || exit 1
+test_rev_parse 'in repo.git/work'         false false true ''
+cd sub/dir || exit 1
+test_rev_parse 'in repo.git/sub/dir' false false true sub/dir/
+cd ../../../.. || exit 1
+
+test_done
-- 
1.5.0.3

^ permalink raw reply related

* [PATCH 6/7] extend rev-parse test for --is-inside-work-tree
From: Matthias Lederhofer @ 2007-06-03 14:48 UTC (permalink / raw)
  To: Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <20070603144401.GA9518@moooo.ath.cx>

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 t/t1500-rev-parse.sh |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index a180309..44cb141 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -17,42 +17,47 @@ test_rev_parse() {
 	shift
 	[ $# -eq 0 ] && return
 
+	test_expect_success "$name: is-inside-work-tree" \
+	"test '$1' = \"\$(git rev-parse --is-inside-work-tree)\""
+	shift
+	[ $# -eq 0 ] && return
+
 	test_expect_success "$name: prefix" \
 	"test '$1' = \"\$(git rev-parse --show-prefix)\""
 	shift
 	[ $# -eq 0 ] && return
 }
 
-test_rev_parse toplevel false false ''
+test_rev_parse toplevel false false true ''
 
 cd .git || exit 1
-test_rev_parse .git/ false true .git/
+test_rev_parse .git/ false true true .git/
 cd objects || exit 1
-test_rev_parse .git/objects/ false true .git/objects/
+test_rev_parse .git/objects/ false true true .git/objects/
 cd ../.. || exit 1
 
 mkdir -p sub/dir || exit 1
 cd sub/dir || exit 1
-test_rev_parse subdirectory false false sub/dir/
+test_rev_parse subdirectory false false true sub/dir/
 cd ../.. || exit 1
 
 git config core.bare true
-test_rev_parse 'core.bare = true' true
+test_rev_parse 'core.bare = true' true false true
 
 git config --unset core.bare
-test_rev_parse 'core.bare undefined' false
+test_rev_parse 'core.bare undefined' false false true
 
-mv .git foo.git || exit 1
-export GIT_DIR=foo.git
-export GIT_CONFIG=foo.git/config
-
-git config core.bare true
-test_rev_parse 'GIT_DIR=foo.git, core.bare = true' true
+mv .git repo.git || exit 1
+export GIT_DIR=repo.git
+export GIT_CONFIG=repo.git/config
 
 git config core.bare false
-test_rev_parse 'GIT_DIR=foo.git, core.bare = false' false
+test_rev_parse 'GIT_DIR=repo.git, core.bare = false' false false true ''
+
+git config core.bare true
+test_rev_parse 'GIT_DIR=repo.git, core.bare = true' true false false
 
 git config --unset core.bare
-test_rev_parse 'GIT_DIR=foo.git, core.bare undefined' true
+test_rev_parse 'GIT_DIR=repo.git, core.bare undefined' true false false
 
 test_done
-- 
1.5.0.3

^ permalink raw reply related

* Re: [RFC] GIT_WORK_TREE
From: Matthias Lederhofer @ 2007-06-03 14:48 UTC (permalink / raw)
  To: Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <20070603144401.GA9518@moooo.ath.cx>

Up to now to check for a working tree this was used:
	!is_bare && !inside_git_dir
(the check for bare is redundant because is_inside_git_dir
returned already 1 for bare repositories).
Now the check is:
	inside_work_tree && !inside_git_dir

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 builtin-ls-files.c |    2 +-
 git-sh-setup.sh    |    2 +-
 git-svn.perl       |    2 +-
 git.c              |   20 ++++++++++----------
 setup.c            |    2 +-
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index f7c066b..48a3135 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -470,7 +470,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
 	}
 
 	if (require_work_tree &&
-			(is_bare_repository() || is_inside_git_dir()))
+			(!is_inside_work_tree() || is_inside_git_dir()))
 		die("This operation must be run in a work tree");
 
 	pathspec = get_pathspec(prefix, argv + i);
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 9ac657a..0de49e8 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -44,7 +44,7 @@ cd_to_toplevel () {
 }
 
 require_work_tree () {
-	test $(is_bare_repository) = false &&
+	test $(git-rev-parse --is-inside-work-tree) = true &&
 	test $(git-rev-parse --is-inside-git-dir) = false ||
 	die "fatal: $0 cannot be used without a working tree."
 }
diff --git a/git-svn.perl b/git-svn.perl
index e3a5cbb..886b898 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -594,7 +594,7 @@ sub post_fetch_checkout {
 	my $index = $ENV{GIT_INDEX_FILE} || "$ENV{GIT_DIR}/index";
 	return if -f $index;
 
-	return if command_oneline(qw/rev-parse --is-bare-repository/) eq 'true';
+	return if command_oneline(qw/rev-parse --is-inside-work-tree/) eq 'false';
 	return if command_oneline(qw/rev-parse --is-inside-git-dir/) eq 'true';
 	command_noisy(qw/read-tree -m -u -v HEAD HEAD/);
 	print STDERR "Checked out HEAD:\n  ",
diff --git a/git.c b/git.c
index 05a391b..cd3910a 100644
--- a/git.c
+++ b/git.c
@@ -224,7 +224,7 @@ const char git_version_string[] = GIT_VERSION;
  * require working tree to be present -- anything uses this needs
  * RUN_SETUP for reading from the configuration file.
  */
-#define NOT_BARE 	(1<<2)
+#define NEED_WORK_TREE	(1<<2)
 
 static void handle_internal_command(int argc, const char **argv, char **envp)
 {
@@ -234,7 +234,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
 		int (*fn)(int, const char **, const char *);
 		int option;
 	} commands[] = {
-		{ "add", cmd_add, RUN_SETUP | NOT_BARE },
+		{ "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
 		{ "annotate", cmd_annotate, RUN_SETUP | USE_PAGER },
 		{ "apply", cmd_apply },
 		{ "archive", cmd_archive },
@@ -244,9 +244,9 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
 		{ "cat-file", cmd_cat_file, RUN_SETUP },
 		{ "checkout-index", cmd_checkout_index, RUN_SETUP },
 		{ "check-ref-format", cmd_check_ref_format },
-		{ "check-attr", cmd_check_attr, RUN_SETUP | NOT_BARE },
+		{ "check-attr", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE },
 		{ "cherry", cmd_cherry, RUN_SETUP },
-		{ "cherry-pick", cmd_cherry_pick, RUN_SETUP | NOT_BARE },
+		{ "cherry-pick", cmd_cherry_pick, RUN_SETUP | NEED_WORK_TREE },
 		{ "commit-tree", cmd_commit_tree, RUN_SETUP },
 		{ "config", cmd_config },
 		{ "count-objects", cmd_count_objects, RUN_SETUP },
@@ -274,7 +274,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
 		{ "mailsplit", cmd_mailsplit },
 		{ "merge-base", cmd_merge_base, RUN_SETUP },
 		{ "merge-file", cmd_merge_file },
-		{ "mv", cmd_mv, RUN_SETUP | NOT_BARE },
+		{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
 		{ "name-rev", cmd_name_rev, RUN_SETUP },
 		{ "pack-objects", cmd_pack_objects, RUN_SETUP },
 		{ "pickaxe", cmd_blame, RUN_SETUP | USE_PAGER },
@@ -287,9 +287,9 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
 		{ "rerere", cmd_rerere, RUN_SETUP },
 		{ "rev-list", cmd_rev_list, RUN_SETUP },
 		{ "rev-parse", cmd_rev_parse, RUN_SETUP },
-		{ "revert", cmd_revert, RUN_SETUP | NOT_BARE },
-		{ "rm", cmd_rm, RUN_SETUP | NOT_BARE },
-		{ "runstatus", cmd_runstatus, RUN_SETUP | NOT_BARE },
+		{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
+		{ "rm", cmd_rm, RUN_SETUP | NEED_WORK_TREE },
+		{ "runstatus", cmd_runstatus, RUN_SETUP | NEED_WORK_TREE },
 		{ "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER },
 		{ "show-branch", cmd_show_branch, RUN_SETUP },
 		{ "show", cmd_show, RUN_SETUP | USE_PAGER },
@@ -326,8 +326,8 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
 			prefix = setup_git_directory();
 		if (p->option & USE_PAGER)
 			setup_pager();
-		if ((p->option & NOT_BARE) &&
-				(is_bare_repository() || is_inside_git_dir()))
+		if ((p->option & NEED_WORK_TREE) &&
+				(!is_inside_work_tree() || is_inside_git_dir()))
 			die("%s must be run in a work tree", cmd);
 		trace_argv_printf(argv, argc, "trace: built-in: git");
 
diff --git a/setup.c b/setup.c
index 4856232..ddf4013 100644
--- a/setup.c
+++ b/setup.c
@@ -95,7 +95,7 @@ void verify_non_filename(const char *prefix, const char *arg)
 	const char *name;
 	struct stat st;
 
-	if (is_inside_git_dir())
+	if (!is_inside_work_tree() || is_inside_git_dir())
 		return;
 	if (*arg == '-')
 		return; /* flag */
-- 
1.5.0.3

^ permalink raw reply related

* [PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree
From: Matthias Lederhofer @ 2007-06-03 14:47 UTC (permalink / raw)
  To: Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <20070603144401.GA9518@moooo.ath.cx>

setup_gdg is used as abbreviation for setup_git_directory_gently.

The work tree can be specified using the environment variable
GIT_WORK_TREE and the config option core.worktree (the environment
variable has precendence over the config option).  Additionally
there is a command line option --work-tree which sets the
environment variable.

setup_gdg does the following now:

GIT_DIR unspecified
repository in .git directory
    parent directory of the .git directory is used as work tree,
    GIT_WORK_TREE is ignored

GIT_DIR unspecified
repository in cwd
    GIT_DIR is set to cwd
    see the cases with GIT_DIR specified what happens next and
    also see the note below

GIT_DIR specified
GIT_WORK_TREE/core.worktree unspecified
repository is bare (config or guessing)
    no work tree is used

GIT_DIR specified
GIT_WORK_TREE/core.worktree unspecified
repository is not bare (config or guessing)
    cwd is used as work tree

GIT_DIR specified
GIT_WORK_TREE/core.worktree specified
    the specified work tree is used

Note on the case where GIT_DIR is unspecified and repository is in cwd:
    GIT_WORK_TREE is used but is_inside_git_dir is always true.
    I did it this way because setup_gdg might be called multiple
    times (e.g. when doing alias expansion) and in successive calls
    setup_gdg should do the same thing every time.

Meaning of is_bare/is_inside_work_tree/is_inside_git_dir:

(1) is_bare_repository
    A repository is bare if core.bare is true or core.bare is
    unspecified and the name suggests it is bare (directory not
    named .git).  In general a bare repository is intended to be
    used without a work tree.  If such a repository is used with a
    work tree anyway some protection mechanisms which are useful
    with a work tree are disabled.  Currently this changes if a
    repository is bare:
        updates of HEAD are allowed
        git gc packs the refs
        the reflog is disabled by default
        cwd is not used as fallback work tree

(2) is_inside_work_tree
    True if the cwd is inside the associated working tree (if there
    is one), false otherwise.

(3) is_inside_git_dir
    True if the cwd is inside the git directory, false otherwise.
    Before this patch is_inside_git_dir was always true for bare
    repositories.

When setup_gdg finds a repository git_config(git_default_config) is
always called.  This ensure that is_bare_repository makes use of
core.bare and does not guess even though core.bare is specified.

inside_work_tree and inside_git_dir are set if setup_gdg finds a
repository.  The is_inside_work_tree and is_inside_git_dir functions
will die if they are called before a successful call to setup_gdg.

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 Documentation/config.txt        |    7 ++
 Documentation/git-rev-parse.txt |    4 +
 Documentation/git.txt           |   18 +++-
 builtin-rev-parse.c             |    5 +
 cache.h                         |    2 +
 connect.c                       |    1 +
 git.c                           |   12 ++-
 setup.c                         |  217 +++++++++++++++++++++++++++++----------
 t/test-lib.sh                   |    1 +
 9 files changed, 210 insertions(+), 57 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 5868d58..4d0bd37 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -172,6 +172,13 @@ repository that ends in "/.git" is assumed to be not bare (bare =
 false), while all other repositories are assumed to be bare (bare
 = true).
 
+core.worktree::
+	Set the path to the working tree.  The value will not be
+	used in combination with repositories found automatically in
+	a .git directory (i.e. $GIT_DIR is not set).
+	This can be overriden by the GIT_WORK_TREE environment
+	variable and the '--work-tree' command line option.
+
 core.logAllRefUpdates::
 	Updates to a ref <ref> is logged to the file
 	"$GIT_DIR/logs/<ref>", by appending the new and old
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index c817d16..6e4d158 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -93,6 +93,10 @@ OPTIONS
 	When the current working directory is below the repository
 	directory print "true", otherwise "false".
 
+--is-inside-work-tree::
+	When the current working directory is inside the work tree of the
+	repository print "true", otherwise "false".
+
 --is-bare-repository::
 	When the repository is bare print "true", otherwise "false".
 
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 98860af..4b567d8 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -10,7 +10,8 @@ SYNOPSIS
 --------
 [verse]
 'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]
-    [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]
+    [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
+    [--help] COMMAND [ARGS]
 
 DESCRIPTION
 -----------
@@ -101,6 +102,14 @@ OPTIONS
 	Set the path to the repository. This can also be controlled by
 	setting the GIT_DIR environment variable.
 
+--work-tree=<path>::
+	Set the path to the working tree.  The value will not be
+	used in combination with repositories found automatically in
+	a .git directory (i.e. $GIT_DIR is not set).
+	This can also be controlled by setting the GIT_WORK_TREE
+	environment variable and the core.worktree configuration
+	variable.
+
 --bare::
 	Same as --git-dir=`pwd`.
 
@@ -345,6 +354,13 @@ git so take care if using Cogito etc.
 	specifies a path to use instead of the default `.git`
 	for the base of the repository.
 
+'GIT_WORK_TREE'::
+	Set the path to the working tree.  The value will not be
+	used in combination with repositories found automatically in
+	a .git directory (i.e. $GIT_DIR is not set).
+	This can also be controlled by the '--work-tree' command line
+	option and the core.worktree configuration variable.
+
 git Commits
 ~~~~~~~~~~~
 'GIT_AUTHOR_NAME'::
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 71d5162..497903a 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -352,6 +352,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 						: "false");
 				continue;
 			}
+			if (!strcmp(arg, "--is-inside-work-tree")) {
+				printf("%s\n", is_inside_work_tree() ? "true"
+						: "false");
+				continue;
+			}
 			if (!strcmp(arg, "--is-bare-repository")) {
 				printf("%s\n", is_bare_repository() ? "true"
 						: "false");
diff --git a/cache.h b/cache.h
index 8a9d1f3..ae1990a 100644
--- a/cache.h
+++ b/cache.h
@@ -192,6 +192,7 @@ enum object_type {
 };
 
 #define GIT_DIR_ENVIRONMENT "GIT_DIR"
+#define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE"
 #define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
 #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
 #define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
@@ -207,6 +208,7 @@ enum object_type {
 extern int is_bare_repository_cfg;
 extern int is_bare_repository(void);
 extern int is_inside_git_dir(void);
+extern int is_inside_work_tree(void);
 extern const char *get_git_dir(void);
 extern char *get_object_directory(void);
 extern char *get_refs_directory(void);
diff --git a/connect.c b/connect.c
index 8cbda88..aafa416 100644
--- a/connect.c
+++ b/connect.c
@@ -589,6 +589,7 @@ pid_t git_connect(int fd[2], char *url, const char *prog, int flags)
 			unsetenv(ALTERNATE_DB_ENVIRONMENT);
 			unsetenv(DB_ENVIRONMENT);
 			unsetenv(GIT_DIR_ENVIRONMENT);
+			unsetenv(GIT_WORK_TREE_ENVIRONMENT);
 			unsetenv(GRAFT_ENVIRONMENT);
 			unsetenv(INDEX_ENVIRONMENT);
 			execlp("sh", "sh", "-c", command, NULL);
diff --git a/git.c b/git.c
index 29b55a1..05a391b 100644
--- a/git.c
+++ b/git.c
@@ -4,7 +4,7 @@
 #include "quote.h"
 
 const char git_usage_string[] =
-	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]";
+	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
 
 static void prepend_to_path(const char *dir, int len)
 {
@@ -69,6 +69,16 @@ static int handle_options(const char*** argv, int* argc)
 			handled++;
 		} else if (!prefixcmp(cmd, "--git-dir=")) {
 			setenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);
+		} else if (!strcmp(cmd, "--work-tree")) {
+			if (*argc < 2) {
+				fprintf(stderr, "No directory given for --work-tree.\n" );
+				usage(git_usage_string);
+			}
+			setenv(GIT_WORK_TREE_ENVIRONMENT, (*argv)[1], 1);
+			(*argv)++;
+			(*argc)--;
+		} else if (!prefixcmp(cmd, "--work-tree=")) {
+			setenv(GIT_WORK_TREE_ENVIRONMENT, cmd + 12, 1);
 		} else if (!strcmp(cmd, "--bare")) {
 			static char git_dir[PATH_MAX+1];
 			setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 1);
diff --git a/setup.c b/setup.c
index a45ea83..4856232 100644
--- a/setup.c
+++ b/setup.c
@@ -174,41 +174,93 @@ static int inside_git_dir = -1;
 
 int is_inside_git_dir(void)
 {
-	if (inside_git_dir < 0) {
-		char buffer[1024];
-
-		if (is_bare_repository())
-			return (inside_git_dir = 1);
-		if (getcwd(buffer, sizeof(buffer))) {
-			const char *git_dir = get_git_dir(), *cwd = buffer;
-			while (*git_dir && *git_dir == *cwd) {
-				git_dir++;
-				cwd++;
-			}
-			inside_git_dir = !*git_dir;
-		} else
-			inside_git_dir = 0;
+	if (inside_git_dir >= 0)
+		return inside_git_dir;
+	die("BUG: is_inside_git_dir called before setup_git_directory");
+}
+
+static int inside_work_tree = -1;
+
+int is_inside_work_tree(void)
+{
+	if (inside_git_dir >= 0)
+		return inside_work_tree;
+	die("BUG: is_inside_work_tree called before setup_git_directory");
+}
+
+static char *gitworktree_config;
+
+static int git_setup_config(const char *var, const char *value)
+{
+	if (!strcmp(var, "core.worktree")) {
+		if (gitworktree_config)
+			strlcpy(gitworktree_config, value, PATH_MAX);
+		return 0;
 	}
-	return inside_git_dir;
+	return git_default_config(var, value);
 }
 
 const char *setup_git_directory_gently(int *nongit_ok)
 {
 	static char cwd[PATH_MAX+1];
-	const char *gitdirenv;
-	int len, offset;
+	char worktree[PATH_MAX+1], gitdir[PATH_MAX+1];
+	const char *gitdirenv, *gitworktree;
+	int wt_rel_gitdir = 0;
 
-	/*
-	 * If GIT_DIR is set explicitly, we're not going
-	 * to do any discovery, but we still do repository
-	 * validation.
-	 */
 	gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
-	if (gitdirenv) {
-		if (PATH_MAX - 40 < strlen(gitdirenv))
-			die("'$%s' too big", GIT_DIR_ENVIRONMENT);
-		if (is_git_directory(gitdirenv))
+	if (!gitdirenv) {
+		int len, offset;
+
+		if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
+			die("Unable to read current working directory");
+
+		offset = len = strlen(cwd);
+		for (;;) {
+			if (is_git_directory(".git"))
+				break;
+			if (offset == 0) {
+				offset = -1;
+				break;
+			}
+			chdir("..");
+			while (cwd[--offset] != '/')
+				; /* do nothing */
+		}
+
+		if (offset >= 0) {
+			inside_work_tree = 1;
+			git_config(git_default_config);
+			if (offset == len) {
+				inside_git_dir = 0;
+				return NULL;
+			}
+
+			cwd[len++] = '/';
+			cwd[len] = '\0';
+			inside_git_dir = !prefixcmp(cwd + offset + 1, ".git/");
+			return cwd + offset + 1;
+		}
+
+		if (chdir(cwd))
+			die("Cannot come back to cwd");
+		if (!is_git_directory(".")) {
+			if (nongit_ok) {
+				*nongit_ok = 1;
+				return NULL;
+			}
+			die("Not a git repository");
+		}
+		setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
+	}
+
+	if (PATH_MAX - 40 < strlen(gitdirenv)) {
+		if (nongit_ok) {
+			*nongit_ok = 1;
 			return NULL;
+		}
+		die("$%s too big", GIT_DIR_ENVIRONMENT);
+	}
+	if (!is_git_directory(gitdirenv)) {
 		if (nongit_ok) {
 			*nongit_ok = 1;
 			return NULL;
@@ -218,41 +270,96 @@ const char *setup_git_directory_gently(int *nongit_ok)
 
 	if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
 		die("Unable to read current working directory");
+	if (chdir(gitdirenv)) {
+		if (nongit_ok) {
+			*nongit_ok = 1;
+			return NULL;
+		}
+		die("Cannot change directory to $%s '%s'",
+			GIT_DIR_ENVIRONMENT, gitdirenv);
+	}
+	if (!getcwd(gitdir, sizeof(gitdir)-1) || gitdir[0] != '/')
+		die("Unable to read current working directory");
+	if (chdir(cwd))
+		die("Cannot come back to cwd");
 
-	offset = len = strlen(cwd);
-	for (;;) {
-		if (is_git_directory(".git"))
-			break;
-		chdir("..");
-		do {
-			if (!offset) {
-				if (is_git_directory(cwd)) {
-					if (chdir(cwd))
-						die("Cannot come back to cwd");
-					setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
-					inside_git_dir = 1;
-					return NULL;
-				}
-				if (nongit_ok) {
-					if (chdir(cwd))
-						die("Cannot come back to cwd");
-					*nongit_ok = 1;
-					return NULL;
-				}
-				die("Not a git repository");
+	/*
+	 * In case there is a work tree we may change the directory,
+	 * therefore make GIT_DIR an absolute path.
+	 */
+	if (gitdirenv[0] != '/') {
+		setenv(GIT_DIR_ENVIRONMENT, gitdir, 1);
+		gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
+		if (PATH_MAX - 40 < strlen(gitdirenv)) {
+			if (nongit_ok) {
+				*nongit_ok = 1;
+				return NULL;
 			}
-		} while (cwd[--offset] != '/');
+			die("$%s too big after expansion to absolute path",
+				GIT_DIR_ENVIRONMENT);
+		}
+	}
+
+	strcat(cwd, "/");
+	strcat(gitdir, "/");
+	inside_git_dir = !prefixcmp(cwd, gitdir);
+
+	gitworktree = getenv(GIT_WORK_TREE_ENVIRONMENT);
+	if (!gitworktree) {
+		gitworktree_config = worktree;
+		worktree[0] = '\0';
+	}
+	git_config(git_setup_config);
+	if (!gitworktree) {
+		gitworktree_config = NULL;
+		if (worktree[0])
+			gitworktree = worktree;
+		if (gitworktree && gitworktree[0] != '/')
+			wt_rel_gitdir = 1;
 	}
 
-	if (offset == len)
+	/* stop if the repository is bare and does not have a work tree */
+	if (!gitworktree && is_bare_repository()) {
+		inside_work_tree = 0;
 		return NULL;
+	}
 
-	/* Make "offset" point to past the '/', and add a '/' at the end */
-	offset++;
-	cwd[len++] = '/';
-	cwd[len] = 0;
-	inside_git_dir = !prefixcmp(cwd + offset, ".git/");
-	return cwd + offset;
+	if (wt_rel_gitdir && chdir(gitdirenv))
+		die("Cannot change directory to $%s '%s'",
+			GIT_DIR_ENVIRONMENT, gitdirenv);
+	if (gitworktree && chdir(gitworktree)) {
+		if (nongit_ok) {
+			if (wt_rel_gitdir && chdir(cwd))
+				die("Cannot come back to cwd");
+			*nongit_ok = 1;
+			return NULL;
+		}
+		if (wt_rel_gitdir)
+			die("Cannot change directory to working tree '%s'"
+				" from $%s", gitworktree, GIT_DIR_ENVIRONMENT);
+		else
+			die("Cannot change directory to working tree '%s'",
+				gitworktree);
+	}
+	if (!getcwd(worktree, sizeof(worktree)-1) || worktree[0] != '/')
+		die("Unable to read current working directory");
+	strcat(worktree, "/");
+	inside_work_tree = !prefixcmp(cwd, worktree);
+
+	if (gitworktree && inside_work_tree && !prefixcmp(worktree, gitdir) &&
+	    strcmp(worktree, gitdir)) {
+		inside_git_dir = 0;
+	}
+
+	if (!inside_work_tree) {
+		if (chdir(cwd))
+			die("Cannot come back to cwd");
+		return NULL;
+	}
+
+	if (!strcmp(cwd, worktree))
+		return NULL;
+	return cwd+strlen(worktree);
 }
 
 int git_config_perm(const char *var, const char *value)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index dee3ad7..b61e1d5 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -26,6 +26,7 @@ GIT_COMMITTER_EMAIL=committer@example.com
 GIT_COMMITTER_NAME='C O Mitter'
 unset GIT_DIFF_OPTS
 unset GIT_DIR
+unset GIT_WORK_TREE
 unset GIT_EXTERNAL_DIFF
 unset GIT_INDEX_FILE
 unset GIT_OBJECT_DIRECTORY
-- 
1.5.0.3

^ permalink raw reply related

* [PATCH 3/7] test git rev-parse
From: Matthias Lederhofer @ 2007-06-03 14:47 UTC (permalink / raw)
  To: Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <20070603144401.GA9518@moooo.ath.cx>

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 t/t1500-rev-parse.sh |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100755 t/t1500-rev-parse.sh

diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
new file mode 100755
index 0000000..a180309
--- /dev/null
+++ b/t/t1500-rev-parse.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+test_description='test git rev-parse'
+. ./test-lib.sh
+
+test_rev_parse() {
+	name=$1
+	shift
+
+	test_expect_success "$name: is-bare-repository" \
+	"test '$1' = \"\$(git rev-parse --is-bare-repository)\""
+	shift
+	[ $# -eq 0 ] && return
+
+	test_expect_success "$name: is-inside-git-dir" \
+	"test '$1' = \"\$(git rev-parse --is-inside-git-dir)\""
+	shift
+	[ $# -eq 0 ] && return
+
+	test_expect_success "$name: prefix" \
+	"test '$1' = \"\$(git rev-parse --show-prefix)\""
+	shift
+	[ $# -eq 0 ] && return
+}
+
+test_rev_parse toplevel false false ''
+
+cd .git || exit 1
+test_rev_parse .git/ false true .git/
+cd objects || exit 1
+test_rev_parse .git/objects/ false true .git/objects/
+cd ../.. || exit 1
+
+mkdir -p sub/dir || exit 1
+cd sub/dir || exit 1
+test_rev_parse subdirectory false false sub/dir/
+cd ../.. || exit 1
+
+git config core.bare true
+test_rev_parse 'core.bare = true' true
+
+git config --unset core.bare
+test_rev_parse 'core.bare undefined' false
+
+mv .git foo.git || exit 1
+export GIT_DIR=foo.git
+export GIT_CONFIG=foo.git/config
+
+git config core.bare true
+test_rev_parse 'GIT_DIR=foo.git, core.bare = true' true
+
+git config core.bare false
+test_rev_parse 'GIT_DIR=foo.git, core.bare = false' false
+
+git config --unset core.bare
+test_rev_parse 'GIT_DIR=foo.git, core.bare undefined' true
+
+test_done
-- 
1.5.0.3

^ permalink raw reply related

* [PATCH 2/7] rev-parse: introduce --is-bare-repository
From: Matthias Lederhofer @ 2007-06-03 14:46 UTC (permalink / raw)
  To: Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <20070603144401.GA9518@moooo.ath.cx>

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 Documentation/git-rev-parse.txt |    3 +++
 builtin-rev-parse.c             |    5 +++++
 git-sh-setup.sh                 |    6 +-----
 git-svn.perl                    |    3 +--
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 5fcec19..c817d16 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -93,6 +93,9 @@ OPTIONS
 	When the current working directory is below the repository
 	directory print "true", otherwise "false".
 
+--is-bare-repository::
+	When the repository is bare print "true", otherwise "false".
+
 --short, --short=number::
 	Instead of outputting the full SHA1 values of object names try to
 	abbreviate them to a shorter unique name. When no length is specified
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 37addb2..71d5162 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -352,6 +352,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 						: "false");
 				continue;
 			}
+			if (!strcmp(arg, "--is-bare-repository")) {
+				printf("%s\n", is_bare_repository() ? "true"
+						: "false");
+				continue;
+			}
 			if (!prefixcmp(arg, "--since=")) {
 				show_datestring("--max-age=", arg+8);
 				continue;
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index f24c7f2..9ac657a 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -29,11 +29,7 @@ set_reflog_action() {
 }
 
 is_bare_repository () {
-	git-config --bool --get core.bare ||
-	case "$GIT_DIR" in
-	.git | */.git) echo false ;;
-	*) echo true ;;
-	esac
+	git-rev-parse --is-bare-repository
 }
 
 cd_to_toplevel () {
diff --git a/git-svn.perl b/git-svn.perl
index e350061..e3a5cbb 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -594,8 +594,7 @@ sub post_fetch_checkout {
 	my $index = $ENV{GIT_INDEX_FILE} || "$ENV{GIT_DIR}/index";
 	return if -f $index;
 
-	chomp(my $bare = `git config --bool --get core.bare`);
-	return if $bare eq 'true';
+	return if command_oneline(qw/rev-parse --is-bare-repository/) eq 'true';
 	return if command_oneline(qw/rev-parse --is-inside-git-dir/) eq 'true';
 	command_noisy(qw/read-tree -m -u -v HEAD HEAD/);
 	print STDERR "Checked out HEAD:\n  ",
-- 
1.5.0.3

^ permalink raw reply related

* [PATCH 1/7] rev-parse: document --is-inside-git-dir
From: Matthias Lederhofer @ 2007-06-03 14:46 UTC (permalink / raw)
  To: Git Mailing List, Nguyen Thai Ngoc Duy
In-Reply-To: <20070603144401.GA9518@moooo.ath.cx>

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 Documentation/git-rev-parse.txt |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 7757abe..5fcec19 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -89,6 +89,10 @@ OPTIONS
 --git-dir::
 	Show `$GIT_DIR` if defined else show the path to the .git directory.
 
+--is-inside-git-dir::
+	When the current working directory is below the repository
+	directory print "true", otherwise "false".
+
 --short, --short=number::
 	Instead of outputting the full SHA1 values of object names try to
 	abbreviate them to a shorter unique name. When no length is specified
-- 
1.5.0.3

^ permalink raw reply related

* [RFC] GIT_WORK_TREE
From: Matthias Lederhofer @ 2007-06-03 14:44 UTC (permalink / raw)
  To: Git Mailing List, Nguyen Thai Ngoc Duy

Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> I think it's a valid use case. Anyone remember why Matthias' patchset
> was dropped?
> It was last mentioned in
> http://article.gmane.org/gmane.comp.version-control.git/43041
> 
> Junio, Matthias? May I help?

Thanks for reminding me, I just did not finish the patch and then
there was an exam which took all my time.  But I took another look at
it and made a new series, including the missing test cases.
If you want to help please test it, check the source for errors, make
comments etc.

This series introduces the GIT_WORK_TREE environment variable (and
core.worktree config option) to specify the working tree that should
be used with the repository (not for repositories found as .git
directory).  This allows to separate the repository and working tree.

Example use cases:
- you don't want to put the repository in the checkout (e.g. the
  checkout is publicly available but the history shouldn't)
- you want to track a read-only directory with git (e.g. track
  configuration files as normal user that are modified by other people
  or by yourself as superuser)
- there is a directory many people are working in and you can track
  the changes made by yourself and others without placing the .git
  directory in the directory
- checkout multiple repositories into the same directory
- see the mail form nguyen (Message-ID:
  <fcaeb9bf0705300742u22b54c78vccbc037fb553141f@mail.gmail.com>)

The patches are also available from git://igit.ath.cx/~matled/git in
branch worktree (I might change this branch later) or as tag
worktree1.

[PATCH] rev-parse: document --is-inside-git-dir
[PATCH] rev-parse: introduce --is-bare-repository
[PATCH] test git rev-parse
[PATCH] introduce GIT_WORK_TREE to specify the work tree
[PATCH] use new semantics of is_bare/inside_git_dir/inside_work_tree
[PATCH] extend rev-parse test for --is-inside-work-tree
[PATCH] test GIT_WORK_TREE

There are also a few things which are not addressed in this series:
- The documentation needs updates on what bare means.
- is_bare_repository should ignore trailing slashes when guessing if
  the repository is bare (/path/to/.git is not bare, /path/to/.git/ is
  bare if core.bare is unspecified).  Perhaps we can also set GIT_DIR
  to the path returned by getcwd which would solve this too.
- Aliases using --git-dir and/or --work-tree cause problems (also
  before this patch).  git should probably exec itself if an alias
  uses --git-dir or --work-tree.
- Calls to git_config(git_default_config) can be removed in many
  places because setup_git_directory_gently always reads the
  configuration.
- git init could set core.worktree if GIT_WORK_TREE is set.

^ permalink raw reply

* Re: [RFC] git integrated bugtracking
From: Johan Herland @ 2007-06-03 13:48 UTC (permalink / raw)
  To: git; +Cc: Pierre Habouzit, Michael Poole
In-Reply-To: <20070603133109.GD14336@artemis>

On Sunday 03 June 2007, Pierre Habouzit wrote:
> On Sun, Jun 03, 2007 at 08:59:18AM -0400, Michael Poole wrote:
> > Pierre Habouzit writes:
> >
> > >   The other problem I see is that at the time a bug gets reported, the
> > > user knows it's found at a commit say 'X'. But it could in fact have
> > > been generated at a commit Y, with this pattern:
> > >
> > >   --o---o---Y---o---o---o---o---X---o---o--> master
> > >                      \
> > >                       o---o---o---o---o---o--> branch B
> > 
> > Mainly for that reason, I would suggest having it outside the code
> > base's namespace: probably a different root in the same $GIT_DIR, but
> > I can see people wanting to have a separate $GIT_DIR.  If the database
> > tracks bugs by what commit(s) introduce or expose the bug -- at least
> > once that is known -- then you get nearly free tracking of which
> > branches have the bug without having to check out largely redundant
> > trees.
> 
>   Sure, but if it's completely out-of-tree, then cloning a repository
> don't allow you to get the bug databases with it for free. I mean it'd
> be great to have it somehow linked to the repository, but also I agree
> that not everybody wants to clone the whole bugs databases. So maybe it
> should just be in another shadow branch that annotates the devel ones.
> Hmmm I definitely need to read the git-note thread...

I guess I'm the one responsible for starting that git-note thread...

For the moment, I'm busy implementing some concepts that came out of that 
discussion (refactoring tag objects and building some infrastructure needed 
to support notes without the drawbacks present in my first version).

Hopefully I'll have a proof-of-concept ready before too long. In the 
meantime I'll be happy to answer questions you might have.

Regarding the notes themselves, I thought about possibly using them as a 
link between the repo and the bug tracker, with some glue code in between 
for making the connections. I haven't thought about integrating them more 
deeply into a bug tracker, but it might be worth thinking along those 
lines, especially for the kind of system you're proposing.

Now, back to hacking...


Have fun! :)

...Johan


-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ 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