Git development
 help / color / mirror / Atom feed
* [PATCH] Unify usage() strings.
From: Junio C Hamano @ 2005-04-20  7:46 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

This patch changes identical cut-and-paste usage strings into a
single instance of static string, to make maintenance easier.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 commit-tree.c |   14 ++++++--------
 diff-cache.c  |    6 ++++--
 diff-tree.c   |    6 ++++--
 read-tree.c   |   10 ++++++----
 4 files changed, 20 insertions(+), 16 deletions(-)



commit-tree.c: 2eee2fe5b14f1f2d86b8d41b501a879b190bf08f
--- a/commit-tree.c
+++ b/commit-tree.c
@@ -268,15 +268,13 @@ static void check_valid(unsigned char *s
 }
 
 /*
- * Having more than two parents may be strange, but hey, there's
- * no conceptual reason why the file format couldn't accept multi-way
- * merges. It might be the "union" of several packages, for example.
- *
- * I don't really expect that to happen, but this is here to make
- * it clear that _conceptually_ it's ok..
+ * Having more than two parents is not strange at all, and this is
+ * how multi-way merges are represented.
  */
 #define MAXPARENT (16)
 
+static char *commit_tree_usage = "commit-tree <sha1> [-p <sha1>]* < changelog";
+
 int main(int argc, char **argv)
 {
 	int i, len;
@@ -296,14 +294,14 @@ int main(int argc, char **argv)
 	unsigned int size;
 
 	if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0)
-		usage("commit-tree <sha1> [-p <sha1>]* < changelog");
+		usage(commit_tree_usage);
 
 	check_valid(tree_sha1, "tree");
 	for (i = 2; i < argc; i += 2) {
 		char *a, *b;
 		a = argv[i]; b = argv[i+1];
 		if (!b || strcmp(a, "-p") || get_sha1_hex(b, parent_sha1[parents]))
-			usage("commit-tree <sha1> [-p <sha1>]* < changelog");
+			usage(commit_tree_usage);
 		check_valid(parent_sha1[parents], "commit");
 		parents++;
 	}


diff-cache.c: 48bcec1230365e12b9fb6df65c15540caea24029
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -215,6 +215,8 @@ static int diff_cache(void *tree, unsign
 	return 0;
 }
 
+static char *diff_cache_usage = "diff-cache [-r] [-z] [--cached] <tree sha1>";
+
 int main(int argc, char **argv)
 {
 	unsigned char tree_sha1[20];
@@ -239,11 +241,11 @@ int main(int argc, char **argv)
 			cached_only = 1;
 			continue;
 		}
-		usage("diff-cache [-r] [-z] <tree sha1>");
+		usage(diff_cache_usage);
 	}
 
 	if (argc != 2 || get_sha1_hex(argv[1], tree_sha1))
-		usage("diff-cache [-r] [-z] <tree sha1>");
+		usage(diff_cache_usage);
 
 	tree = tree_from_tree_or_commit(tree_sha1, type, &size);
 	if (!tree)
diff-tree.c: 8720ce75b72cdf9c8d189f9edf41e0920bd72767
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -193,6 +193,8 @@ static void commit_to_tree(unsigned char
 	}
 }
 
+static char *diff_tree_usage = "diff-tree [-r] [-z] <tree sha1> <tree sha1>";
+
 int main(int argc, char **argv)
 {
 	unsigned char old[20], new[20];
@@ -209,11 +211,11 @@ int main(int argc, char **argv)
 			line_termination = '\0';
 			continue;
 		}
-		usage("diff-tree [-r] [-z] <tree sha1> <tree sha1>");
+		usage(diff_tree_usage);
 	}
 
 	if (argc != 3 || get_sha1_hex(argv[1], old) || get_sha1_hex(argv[2], new))
-		usage("diff-tree <tree sha1> <tree sha1>");
+		usage(diff_tree_usage);
 	commit_to_tree(old);
 	commit_to_tree(new);
 	return diff_tree_sha1(old, new, "");


read-tree.c: e438579d63fb090209eaf4c864586afaeb52ae0f
--- a/read-tree.c
+++ b/read-tree.c
@@ -201,6 +201,8 @@ static void merge_stat_info(struct cache
 	}
 }
 
+static char *read_tree_usage = "read-tree (<sha> | -m <sha1> [<sha2> <sha3>])";
+
 int main(int argc, char **argv)
 {
 	int i, newfd, merge;
@@ -220,20 +222,20 @@ int main(int argc, char **argv)
 		if (!strcmp(arg, "-m")) {
 			int i;
 			if (stage)
-				usage("-m needs to come first");
+				die("-m needs to come first");
 			read_cache();
 			for (i = 0; i < active_nr; i++) {
 				if (ce_stage(active_cache[i]))
-					usage("you need to resolve your current index first");
+					die("you need to resolve your current index first");
 			}
 			stage = 1;
 			merge = 1;
 			continue;
 		}
 		if (get_sha1_hex(arg, sha1) < 0)
-			usage("read-tree [-m] <sha1>");
+			usage(read_tree_usage);
 		if (stage > 3)
-			usage("can't merge more than two trees");
+			usage(read_tree_usage);
 		if (read_tree(sha1, "", 0) < 0)
 			die("failed to unpack tree object %s", arg);
 		stage++;


^ permalink raw reply

* enforcing DB immutability
From: Ingo Molnar @ 2005-04-20  7:40 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: H. Peter Anvin, git
In-Reply-To: <Pine.LNX.4.58.0504131404380.4501@ppc970.osdl.org>


* Linus Torvalds <torvalds@osdl.org> wrote:

> On Wed, 13 Apr 2005, Ingo Molnar wrote:
> > 
> > well, the 'owned by another user' solution is valid though, and doesnt 
> > have this particular problem. (We've got a secure multiuser OS, so can 
> > as well use it to protect the DB against corruption.)
> 
> So now you need root to set up new repositories? No thanks.

yeah, it's a bit awkward to protect uncompressed repositories - but it 
will need some sort of kernel enforcement. (if userspace finds out the 
DB contains uncompressed blobs, it _will_ try to use them.)

(perhaps having an in-kernel GIT-alike versioned filesystem will help - 
but that brings up the same 'I have to be root' issues. The FS will 
enforce the true immutability of objects.)

perhaps having a new 'immutable hardlink' feature in the Linux VFS would 
help? I.e. a hardlink that can only be readonly followed, and can be 
removed, but cannot be chmod-ed to a writeable hardlink. That i think 
would be a large enough barrier for editors/build-tools not to play the 
tricks they already do that makes 'readonly' files virtually 
meaningless.

	Ingo

^ permalink raw reply

* Re: [PATCH] write-tree performance problems
From: H. Peter Anvin @ 2005-04-20  7:38 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Chris Mason, git
In-Reply-To: <Pine.LNX.4.58.0504192337120.6467@ppc970.osdl.org>

Linus Torvalds wrote:
> 
> So I'll see if I can turn the current fsck into a "convert into
> uncompressed format", and do a nice clean format conversion. 
> 

Just let me know what you want to do, and I can trivially change the 
conversion scripts I've already written to do what you want.

	-hpa

^ permalink raw reply

* Re: Change "pull" to _only_ download, and "git update"=pull+merge?
From: Ingo Molnar @ 2005-04-20  7:01 UTC (permalink / raw)
  To: Petr Baudis
  Cc: Martin Schlemmer, David Greaves, dwheeler, Daniel Barkalow, git
In-Reply-To: <20050419105008.GB12757@pasky.ji.cz>


* Petr Baudis <pasky@ucw.cz> wrote:

> > I think pull is pull.  If you are doing lots of local stuff and do not
> > want it overwritten, it should have been in a forked branch.
> 
> I disagree. This already forces you to have two branches (one to pull 
> from to get the data, mirroring the remote branch, one for your real 
> work) uselessly and needlessly.
> 
> I think there is just no good name for what pull is doing now, and 
> update seems like a great name for what pull-and-merge really is. Pull 
> really is pull - it _pulls_ the data, while update also updates the 
> given tree. No surprises.

yeah. In fact most of the times i did 'git pull pasky' in the past, the 
'merge' phase was unsuccessful, and i had to nuke the tree and recreate 
it.  All i did with the snapshots was to build them, so there were no 
local changes. Waiting a couple of days with doing a 'git pull pasky', 
or installing Linus' tree is a sure way to break the merging.

e.g. to reproduce the last such failure i had today, do:

 cd git-pasky-base
 echo 8568e1a88c086d1b72b0e84ab24fa6888b5861b9 > .git/HEAD
 read-tree $(tree-id $(cat .git/HEAD))
 checkout-cache -a -f
 make
 make install           # make sure to use the older tools
 rm -rf .git/objects
 git pull pasky

and i get:

 [...]
 fatal: unable to execute 'gitmerge-file.sh'
 fatal: merge program failed

        Conflicts during merge. Do git commit after resolving them.

note that with earlier versions of pasky, i had other merge conflicts.  
Sometimes there were .rej files, sometimes some sort of script failure.  
So it seems rather unrobust at the moment. Especially if i happen to 
install Linus' tree and try to sync the pasky tree with those tools.

another thing: it's confusing that during 'git pull', the rsync output 
is not visible. Especially during large rsyncs, it would be nice to see 
some progress. So i usually use a raw rsync not 'git pull', due to this.

yet another thing: what is the canonical 'pasky way' of simply nuking 
the current files and checking out the latest tree (according to 
.git/HEAD). Right now i'm using a script to:

  read-tree $(tree-id $(cat .git/HEAD))
  checkout-cache -a

(i first do an 'rm -f *' in the working directory)

i guess there's an existing command for this already?

	Ingo

^ permalink raw reply

* Re: [PATCH] write-tree performance problems
From: Linus Torvalds @ 2005-04-20  6:43 UTC (permalink / raw)
  To: Chris Mason; +Cc: git
In-Reply-To: <200504192049.21947.mason@suse.com>



On Tue, 19 Apr 2005, Chris Mason wrote:
> 
> I'll finish off the patch once you ok the basics below.  My current code works 
> like this:

Chris, before you do anything further, let me re-consider.

Assuming that the real cost of write-tree is the compression (and I think
it is), I really suspect that this ends up being the death-knell to my
"use the sha1 of the _compressed_ object" approach. I thought it was
clever, and I was ready to ignore the other arguments against it, but if
it turns out that we can speed up write-tree a lot by just doing the SHA1
on the uncompressed data, and noticing that we already have the tree
before we need to compress it and write it out, then that may be a good
enough reason for me to just admit that I was wrong about that decision.

So I'll see if I can turn the current fsck into a "convert into
uncompressed format", and do a nice clean format conversion. 

Most of git is very format-agnostic, so that shouldn't be that painful. 
Knock wood.

			Linus

^ permalink raw reply

* (fixed) [PATCH 1/4] Accept commit in some places when tree is needed.
From: Junio C Hamano @ 2005-04-20  6:35 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
In-Reply-To: <7vis2ikmj0.fsf@assigned-by-dhcp.cox.net>

<cover-paragraph>
_BLUSH_  

The 1/4 in the series was a buggy one I sent by mistake.  Please
replace it with this fixed one.  The other three are OK.

BTW, do you have a preferred patch-mail convention to mark the
cover paragraph like this to be excluded from the commit log,
like the three-dash one you mentioned to exclude the tail of
the message?
</cover-paragraph>

Similar to diff-cache which was introduced recently, when the
intent is obvious we should accept commit ID when tree ID is
required.  This patch lifts the tree-from-tree-or-commit logic
from diff-cache.c and moves it to sha1_file.c, which is a common
library source for the SHA1 storage part.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 cache.h      |    1 +
 diff-cache.c |   19 ++-----------------
 sha1_file.c  |   29 +++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 17 deletions(-)

--- a/cache.h
+++ b/cache.h
@@ -124,5 +124,6 @@ extern void die(const char *err, ...);
 extern int error(const char *err, ...);
 
 extern int cache_name_compare(const char *name1, int len1, const char *name2, int len2);
+extern void *tree_from_tree_or_commit(const unsigned char *sha1, char *type, unsigned long *size);
 
 #endif /* CACHE_H */
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -245,23 +245,8 @@ int main(int argc, char **argv)
 	if (argc != 2 || get_sha1_hex(argv[1], tree_sha1))
 		usage("diff-cache [-r] [-z] <tree sha1>");
 
-	tree = read_sha1_file(tree_sha1, type, &size);
+	tree = tree_from_tree_or_commit(tree_sha1, type, &size);
 	if (!tree)
-		die("bad tree object %s", argv[1]);
-
-	/* We allow people to feed us a commit object, just because we're nice */
-	if (!strcmp(type, "commit")) {
-		/* tree sha1 is always at offset 5 ("tree ") */
-		if (get_sha1_hex(tree + 5, tree_sha1))
-			die("bad commit object %s", argv[1]);
-		free(tree);
-		tree = read_sha1_file(tree_sha1, type, &size);       
-		if (!tree)
-			die("unable to read tree object %s", sha1_to_hex(tree_sha1));
-	}
-
-	if (strcmp(type, "tree"))
-		die("bad tree object %s (%s)", sha1_to_hex(tree_sha1), type);
-
+		die("cannot get tree object from %s", argv[1]);
 	return diff_cache(tree, size, active_cache, active_nr, "");
 }
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -245,3 +245,32 @@ int write_sha1_buffer(const unsigned cha
 	close(fd);
 	return 0;
 }
+
+void *tree_from_tree_or_commit(const unsigned char *sha1, char *type,
+			       unsigned long *size)
+{
+	void *tree = read_sha1_file(sha1, type, size);
+	if (!tree)
+		return tree;
+
+	/* We allow people to feed us a commit object,
+	 * just because we're nice.
+	 */
+	if (!strcmp(type, "commit")) {
+		/* tree sha1 is always at offset 5 ("tree ") */
+		char tree_sha1[20];
+		if (get_sha1_hex(tree + 5, tree_sha1)) {
+			free(tree);
+			return NULL;
+		}
+		free(tree);
+		tree = read_sha1_file(tree_sha1, type, size);
+		if (!tree)
+			return NULL;
+	}
+	if (strcmp(type , "tree")) {
+		free(tree);
+		return NULL;
+	}
+	return tree;
+}


^ permalink raw reply

* [PATCH 4/4] Use tree_from_tree_or_commit() in ls-tree.
From: Junio C Hamano @ 2005-04-20  6:11 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

This patch makes ls-tree accept either tree or commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 ls-tree.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

Makefile: needs update
cache.h: needs update
sha1_file.c: needs update
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -74,7 +74,7 @@ static int list(unsigned char *sha1)
 	unsigned long size;
 	char type[20];
 
-	buffer = read_sha1_file(sha1, type, &size);
+	buffer = tree_from_tree_or_commit(sha1, type, &size);
 	if (!buffer)
 		die("unable to read sha1 file");
 	list_recursive(buffer, type, size, NULL);


^ permalink raw reply

* [PATCH 3/4] Use tree_from_tree_or_commit() in diff-tree.
From: Junio C Hamano @ 2005-04-20  6:10 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

This patch makes diff-tree accept either tree or commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 diff-tree.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

--- a/diff-tree.c
+++ b/diff-tree.c
@@ -160,18 +160,20 @@ static int diff_tree(void *tree1, unsign
 	return 0;
 }
 
-static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const char *base)
+static int diff_tree_sha1(const unsigned char *old,
+			  const unsigned char *new,
+			  const char *base)
 {
 	void *tree1, *tree2;
 	unsigned long size1, size2;
 	char type[20];
 	int retval;
 
-	tree1 = read_sha1_file(old, type, &size1);
-	if (!tree1 || strcmp(type, "tree"))
+	tree1 = tree_from_tree_or_commit(old, type, &size1);
+	if (!tree1)
 		die("unable to read source tree (%s)", sha1_to_hex(old));
-	tree2 = read_sha1_file(new, type, &size2);
-	if (!tree2 || strcmp(type, "tree"))
+	tree2 = tree_from_tree_or_commit(new, type, &size2);
+	if (!tree2)
 		die("unable to read destination tree (%s)", sha1_to_hex(new));
 	retval = diff_tree(tree1, size1, tree2, size2, base);
 	free(tree1);


^ permalink raw reply

* [PATCH 2/4] Use tree_from_tree_or_commit() in read-tree.
From: Junio C Hamano @ 2005-04-20  6:09 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

This patch makes read-tree accept either tree or commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 read-tree.c |    4 +---
 1 files changed, 1 insertion(+), 3 deletions(-)

Makefile: needs update
--- a/read-tree.c
+++ b/read-tree.c
@@ -29,11 +29,9 @@ static int read_tree(unsigned char *sha1
 	unsigned long size;
 	char type[20];
 
-	buffer = read_sha1_file(sha1, type, &size);
+	buffer = tree_from_tree_or_commit(sha1, type, &size);
 	if (!buffer)
 		return -1;
-	if (strcmp(type, "tree"))
-		return -1;
 	while (size) {
 		int len = strlen(buffer)+1;
 		unsigned char *sha1 = buffer + len;


^ permalink raw reply

* [PATCH 1/4] Accept commit in some places when tree is needed.
From: Junio C Hamano @ 2005-04-20  6:08 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

Similar to the diff-cache command, we should accept commit ID
when tree ID is required but the end-user intent is unambiguous.

This patch lifts the tree-from-tree-or-commit logic from
diff-cache.c and moves it to sha1_file.c, which is a common
library source for the SHA1 storage part.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 cache.h      |    1 +
 diff-cache.c |   18 ++----------------
 sha1_file.c  |   28 ++++++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 16 deletions(-)

Makefile: needs update
--- a/cache.h
+++ b/cache.h
@@ -124,5 +124,6 @@ extern void die(const char *err, ...);
 extern int error(const char *err, ...);
 
 extern int cache_name_compare(const char *name1, int len1, const char *name2, int len2);
+extern void *tree_from_tree_or_commit(unsigned char *sha1, char *type, unsigned long *size);
 
 #endif /* CACHE_H */
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -245,23 +245,9 @@ int main(int argc, char **argv)
 	if (argc != 2 || get_sha1_hex(argv[1], tree_sha1))
 		usage("diff-cache [-r] [-z] <tree sha1>");
 
+	tree = tree_from_tree_or_commit(tree_sha1, type, &size);
 	tree = read_sha1_file(tree_sha1, type, &size);
 	if (!tree)
-		die("bad tree object %s", argv[1]);
-
-	/* We allow people to feed us a commit object, just because we're nice */
-	if (!strcmp(type, "commit")) {
-		/* tree sha1 is always at offset 5 ("tree ") */
-		if (get_sha1_hex(tree + 5, tree_sha1))
-			die("bad commit object %s", argv[1]);
-		free(tree);
-		tree = read_sha1_file(tree_sha1, type, &size);       
-		if (!tree)
-			die("unable to read tree object %s", sha1_to_hex(tree_sha1));
-	}
-
-	if (strcmp(type, "tree"))
-		die("bad tree object %s (%s)", sha1_to_hex(tree_sha1), type);
-
+		die("cannot get tree object from %s", argv[1]);
 	return diff_cache(tree, size, active_cache, active_nr, "");
 }
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -245,3 +245,31 @@ int write_sha1_buffer(const unsigned cha
 	close(fd);
 	return 0;
 }
+
+void *tree_from_tree_or_commit(unsigned char *sha1, char *type,
+			       unsigned long *size)
+{
+	void *tree = read_sha1_file(sha1, type, size);
+	if (!tree)
+		return tree;
+
+	/* We allow people to feed us a commit object,
+	 * just because we're nice.
+	 */
+	if (!strcmp(type, "commit")) {
+		/* tree sha1 is always at offset 5 ("tree ") */
+		if (get_sha1_hex(tree + 5, sha1)) {
+			free(tree);
+			return NULL;
+		}
+		free(tree);
+		tree = read_sha1_file(sha1, type, size);
+		if (!tree)
+			return NULL;
+	}
+	if (strcmp(type , "tree")) {
+		free(tree);
+		return NULL;
+	}
+	return tree;
+}


^ permalink raw reply

* Re: [RFC] Possible strategy cleanup for git add/remove/diff etc.
From: Junio C Hamano @ 2005-04-20  6:07 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Petr Baudis, git
In-Reply-To: <Pine.LNX.4.58.0504192102140.6467@ppc970.osdl.org>

>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:

>> I'll immediately write a tool to diff the current working directory 
>> against a tree object, and hopefully that will just make pasky happy with 
>> this model too. 

The model you have always had is that there are three things the
user needs to be aware of:

 * files in working tree -- this is what you touch with your
   editor and feed compilers with.

 * files in dircache -- update-cache copies from working
   tree to here, checkout-cache copies from here to working
   tree.

 * committed tree state -- write-tree + commit-tree copies from
   dircache to this state, read-tree copies from here to
   dircache.

The original message I started this thread with suggested that I
wish if Cogito sugarcoating layer treated the dircache invisible
to the user by keeping it virtually and lazily in sync with the
working tree, as opposed to the way the current git-pasky does,
which is to keep it in sync with the committed state.

But after thinking about it more, I changed my mind.  With
something like diff-cache available to the user, making aware of
the three hierarchy to the user might be cleaner.  

The workflow becomes:
 
 * Initial read-tree + checkout-cache -f -a; makes the three in
   sync.

 * Hack away.  Makes the working tree drift from dircache.

 * show-diff to see what's changed since your last "checkpoint".
   update-cache when happy.  Working tree is in sync with
   dircache which is the "staging area" for my half-baked but
   still good stuff.  Makes the dircache different from the
   committed.

 * Hack away more.  show-diff does not show your earlier changes
   anymore.  This is sometimes inconvenient when you want to see
   what you earlier changed but not committed.  Here comes the
   new shiny diff-cache to rescue.

 * When satisfied with all the changes diff-cache --cached
   shows, finally, say write-tree + commit-tree.  This makes all
   three in sync again.

I vaguely recall having heard about some SCM that distinguishes
check-in and commit.  Maybe this two-staged update-cache and
write-tree + commit-tree workflow is similar to it?


^ permalink raw reply

* Re: [PATCH 2/3] init-db.c: normalize env var handling.
From: Linus Torvalds @ 2005-04-20  4:59 UTC (permalink / raw)
  To: Zach Welch; +Cc: git
In-Reply-To: <4265E0BB.4040700@superlucidity.net>



On Tue, 19 Apr 2005, Zach Welch wrote:
> 
> I feel even more abashed for my earlier scripting faux pas. Would you
> like me to resend them to you off-list?

No, I edited them and applied them (the first series, I'll have to think 
about the second one).

It's only when there are tens of patches that it gets really old really 
quickly to edit things by hand. Three I can handle ;)

		Linus

^ permalink raw reply

* Re: [PATCH 2/3] init-db.c: normalize env var handling.
From: Zach Welch @ 2005-04-20  4:55 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.58.0504192142040.6467@ppc970.osdl.org>

Linus Torvalds wrote:
> For future reference, this is in the wrong order.

I feel even more abashed for my earlier scripting faux pas. Would you
like me to resend them to you off-list?

Cheers,

Zach



^ permalink raw reply

* Re: [PATCH 2/3] init-db.c: normalize env var handling.
From: Linus Torvalds @ 2005-04-20  4:45 UTC (permalink / raw)
  To: Zach Welch; +Cc: git
In-Reply-To: <mailbox-1242-1113971319-971926@spoon>



On Tue, 19 Apr 2005, Zach Welch wrote:
>
> This patch applies on top of:
>         [PATCH 1/3] init-db.c: cleanup comments
> 
>  init-db.c |   11 +++--------
>  1 files changed, 3 insertions(+), 8 deletions(-)
> 
> Signed-Off-By: Zach Welch <zw@superlucidity.net>
> 
> Normalize init-db environment variable handling, allowing the creation
> of object directories with something other than DEFAULT_DB_ENVIRONMENT.
> 
> --- a/init-db.c
> +++ b/init-db.c

For future reference, this is in the wrong order.

You should have "checkin comment" first, then "signed-off-by", then a line 
with three dashes, and then "administrative trivia".

Ie I'd much rather see the email look like

	Normalize init-db environment variable handling, allowing the creation
	of object directories with something other than DEFAULT_DB_ENVIRONMENT.
	
	Signed-Off-By: Zach Welch <zw@superlucidity.net>
	---
	This patch applies on top of:
	        [PATCH 1/3] init-db.c: cleanup comments
	
	 init-db.c |   11 +++--------
	 1 files changed, 3 insertions(+), 8 deletions(-)
	
	.. actual patch goes here ..

since otherwise I'll just have to edit it that way. I like seeing the 
administrative stuff (diffstat etc), but I don't want to have it in the 
commit message, and that's exactly what the "---" marker is for - my tools 
will automatically cut it off as if it was a signature (or the beginning 
of the patch).

		Linus

^ permalink raw reply

* [PATCH 3/3] rename SHA1_FILE_DIRECTORY
From: Zach Welch @ 2005-04-20  4:32 UTC (permalink / raw)
  To: git; +Cc: torvalds

This patch applies on top of:
        [PATCH 1/3] add GIT_CACHE_DIRECTORY support
        [PATCH 2/3] rename object directory symbols

 cache.h |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

Signed-Off-By: Zach Welch <zw@superlucidity.net>

Rename SHA1_FILE_DIRECTORY to GIT_OBJECT_DIRECTORY.  Scripts that
used to pass this setting will need to be updated.

cache.h: 218bec12fab3fb57ad03fafccedd4398c64c3646
--- a/cache.h
+++ b/cache.h
@@ -84,7 +84,7 @@ unsigned int active_nr, active_alloc;
 #define GIT_CACHE_ENVIRONMENT "GIT_CACHE_DIRECTORY"
 #define DEFAULT_GIT_CACHE_ENVIRONMENT ".git"
 
-#define GIT_OBJECT_ENVIRONMENT "SHA1_FILE_DIRECTORY"
+#define GIT_OBJECT_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
 #define DEFAULT_GIT_OBJECT_ENVIRONMENT ".git/objects"
 
 #define alloc_nr(x) (((x)+16)*3/2)

^ permalink raw reply

* [PATCH 2/3] rename object directory symbols
From: Zach Welch @ 2005-04-20  4:32 UTC (permalink / raw)
  To: git; +Cc: torvalds

This patch applies on top of:
        [PATCH 1/3] add GIT_CACHE_DIRECTORY support

 cache.h      |    4 ++--
 fsck-cache.c |    2 +-
 init-db.c    |    4 ++--
 ls-tree.c    |    4 ++--
 read-cache.c |    4 ++--
 sha1_file.c  |    2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)

Signed-Off-By: Zach Welch <zw@superlucidity.net>

Rename the DB_ENVIRONMENT symbols to match the newly introduced
GIT_CACHE_ENVIROMENT symbols.

cache.h: 1fca894f485471d51c6a72c16e02df6d56d0052f
--- a/cache.h
+++ b/cache.h
@@ -84,8 +84,8 @@ unsigned int active_nr, active_alloc;
 #define GIT_CACHE_ENVIRONMENT "GIT_CACHE_DIRECTORY"
 #define DEFAULT_GIT_CACHE_ENVIRONMENT ".git"
 
-#define DB_ENVIRONMENT "SHA1_FILE_DIRECTORY"
-#define DEFAULT_DB_ENVIRONMENT ".git/objects"
+#define GIT_OBJECT_ENVIRONMENT "SHA1_FILE_DIRECTORY"
+#define DEFAULT_GIT_OBJECT_ENVIRONMENT ".git/objects"
 
 #define alloc_nr(x) (((x)+16)*3/2)
 
fsck-cache.c: cf39b7e054d9685fde7004ec767cd098b97e8ce7
--- a/fsck-cache.c
+++ b/fsck-cache.c
@@ -135,7 +135,7 @@ int main(int argc, char **argv)
 	int i, heads;
 	char *sha1_dir;
 
-	sha1_dir = getenv(DB_ENVIRONMENT) ? : DEFAULT_DB_ENVIRONMENT;
+	sha1_dir = getenv(GIT_OBJECT_ENVIRONMENT) ? : DEFAULT_GIT_OBJECT_ENVIRONMENT;
 	for (i = 0; i < 256; i++) {
 		static char dir[4096];
 		sprintf(dir, "%s/%02x", sha1_dir, i);
init-db.c: 9e693a0a914512c5574f394222cfc75496e3453a
--- a/init-db.c
+++ b/init-db.c
@@ -33,9 +33,9 @@ int main(int argc, char **argv)
 	}	
 	safe_create_dir(git_dir);
 
-	sha1_dir = getenv(DB_ENVIRONMENT);
+	sha1_dir = getenv(GIT_OBJECT_ENVIRONMENT);
 	if (!sha1_dir) {
-		sha1_dir = DEFAULT_DB_ENVIRONMENT;
+		sha1_dir = DEFAULT_GIT_OBJECT_ENVIRONMENT;
 		fprintf(stderr, "defaulting to local storage area\n");
 	}
 	len = strlen(sha1_dir);
ls-tree.c: 936bb19a5525046a5a784d5f14c3ea7da406cc62
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -105,9 +105,9 @@ int main(int argc, char **argv)
 		usage(ls_tree_usage);
 	if (get_sha1_hex(argv[1], sha1) < 0)
 		usage(ls_tree_usage);
-	sha1_file_directory = getenv(DB_ENVIRONMENT);
+	sha1_file_directory = getenv(GIT_OBJECT_ENVIRONMENT);
 	if (!sha1_file_directory)
-		sha1_file_directory = DEFAULT_DB_ENVIRONMENT;
+		sha1_file_directory = DEFAULT_GIT_OBJECT_ENVIRONMENT;
 	if (list(sha1) < 0)
 		die("list failed");
 	return 0;
read-cache.c: 9eee23097b9406548765ec6fc77e61788317df19
--- a/read-cache.c
+++ b/read-cache.c
@@ -186,9 +186,9 @@ int read_cache(void)
 		return error("more than one cachefile");
 	errno = ENOENT;
 
-	sha1_file_directory = getenv(DB_ENVIRONMENT);
+	sha1_file_directory = getenv(GIT_OBJECT_ENVIRONMENT);
 	if (!sha1_file_directory)
-		sha1_file_directory = DEFAULT_DB_ENVIRONMENT;
+		sha1_file_directory = DEFAULT_GIT_OBJECT_ENVIRONMENT;
 	if (access(sha1_file_directory, X_OK) < 0)
 		return error("no access to SHA1 file directory");
 
sha1_file.c: c4591cd2168ae2e42c1fc9878be8befbfa1a8afa
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -61,7 +61,7 @@ char *sha1_file_name(const unsigned char
 	static char *name, *base;
 
 	if (!base) {
-		char *sha1_file_directory = getenv(DB_ENVIRONMENT) ? : DEFAULT_DB_ENVIRONMENT;
+		char *sha1_file_directory = getenv(GIT_OBJECT_ENVIRONMENT) ? : DEFAULT_GIT_OBJECT_ENVIRONMENT;
 		int len = strlen(sha1_file_directory);
 		base = malloc(len + 60);
 		memcpy(base, sha1_file_directory, len);

^ permalink raw reply

* [PATCH 1/3] add GIT_CACHE_DIRECTORY support
From: Zach Welch @ 2005-04-20  4:32 UTC (permalink / raw)
  To: git; +Cc: torvalds

 cache.h        |    3 +++
 init-db.c      |    9 +++++++--
 read-cache.c   |   15 +++++++++++++--
 read-tree.c    |   35 ++++++++++++++++++++++++++---------
 update-cache.c |   33 ++++++++++++++++++++++++---------
 5 files changed, 73 insertions(+), 22 deletions(-)

Signed-Off-By: Zach Welch <zw@superlucidity.net>

This patch introduces the GIT_CACHE_DIRECTORY to the C plumbing.
Without this patch, the index file and its lock are always placed
in './.git'.  Scripts wishing to run these commands from a different 
working directory can use this support to override the cache directory.

This require my latest init-db cleanups be applied first, otherwise
you will get a rejection in init-db.c.

cache.h: 5948db759b3f6fb5ade3b027f202330f71a8cb6a
--- a/cache.h
+++ b/cache.h
@@ -81,6 +81,9 @@ const char *sha1_file_directory;
 struct cache_entry **active_cache;
 unsigned int active_nr, active_alloc;
 
+#define GIT_CACHE_ENVIRONMENT "GIT_CACHE_DIRECTORY"
+#define DEFAULT_GIT_CACHE_ENVIRONMENT ".git"
+
 #define DB_ENVIRONMENT "SHA1_FILE_DIRECTORY"
 #define DEFAULT_DB_ENVIRONMENT ".git/objects"
 
init-db.c: 14beb35657de229a61673198bfc4e009daafca15
--- a/init-db.c
+++ b/init-db.c
@@ -23,10 +23,15 @@ void safe_create_dir(char *dir)
  */
 int main(int argc, char **argv)
 {
-	char *sha1_dir, *path;
+	char *sha1_dir, *path, *git_dir;
 	int len, i;
 
-	safe_create_dir(".git");
+	git_dir = getenv(GIT_CACHE_ENVIRONMENT);
+	if (!git_dir) {
+		git_dir = DEFAULT_GIT_CACHE_ENVIRONMENT;
+		fprintf(stderr, "defaulting to local cache area\n");
+	}	
+	safe_create_dir(git_dir);
 
 	sha1_dir = getenv(DB_ENVIRONMENT);
 	if (!sha1_dir) {
read-cache.c: edaadf3e1c0714735ca8d80301dd644aa0f9cd2a
--- a/read-cache.c
+++ b/read-cache.c
@@ -174,22 +174,33 @@ static int verify_hdr(struct cache_heade
 
 int read_cache(void)
 {
-	int fd, i;
+	int fd, i, len;
 	struct stat st;
 	unsigned long size, offset;
 	void *map;
 	struct cache_header *hdr;
+	char *index_path, *index_file;
 
 	errno = EBUSY;
 	if (active_cache)
 		return error("more than one cachefile");
 	errno = ENOENT;
+
 	sha1_file_directory = getenv(DB_ENVIRONMENT);
 	if (!sha1_file_directory)
 		sha1_file_directory = DEFAULT_DB_ENVIRONMENT;
 	if (access(sha1_file_directory, X_OK) < 0)
 		return error("no access to SHA1 file directory");
-	fd = open(".git/index", O_RDONLY);
+
+	index_path = getenv(GIT_CACHE_ENVIRONMENT);
+	if (!index_path)
+		index_path = DEFAULT_GIT_CACHE_ENVIRONMENT;
+	len = strlen(index_path);
+	index_file = malloc(len + 7);
+	if (!index_file) error("out of memory");
+	sprintf(index_file, "%s/index", index_path);
+
+	fd = open(index_file, O_RDONLY);
 	if (fd < 0)
 		return (errno == ENOENT) ? 0 : error("open failed");
 
read-tree.c: 9bcba2d567e1c86ae967d383cc081e6947d00a13
--- a/read-tree.c
+++ b/read-tree.c
@@ -65,12 +65,12 @@ static int read_tree(unsigned char *sha1
 	return 0;
 }
 
-static int remove_lock = 0;
+static char *index_lock = NULL;
 
 static void remove_lock_file(void)
 {
-	if (remove_lock)
-		unlink(".git/index.lock");
+	if (index_lock)
+		unlink(index_lock);
 }
 
 static int path_matches(struct cache_entry *a, struct cache_entry *b)
@@ -205,14 +205,27 @@ static void merge_stat_info(struct cache
 
 int main(int argc, char **argv)
 {
-	int i, newfd, merge;
+	int i, newfd, len, merge;
 	unsigned char sha1[20];
-
-	newfd = open(".git/index.lock", O_RDWR | O_CREAT | O_EXCL, 0600);
+ 	char *index_file, *index_path;
+  
+ 	index_path = getenv(GIT_CACHE_ENVIRONMENT);
+ 	if (!index_path)
+ 		index_path = DEFAULT_GIT_CACHE_ENVIRONMENT;
+ 
+ 	len = strlen(index_path);
+ 	index_file = malloc(len + 7);
+ 	if (!index_file) error("out of memory");
+ 	sprintf(index_file, "%s/index", index_path);
+ 
+ 	index_lock = malloc(len + 12);
+ 	if (!index_lock) error("out of memory");
+ 	sprintf(index_lock, "%s/index.lock", index_path);
+ 
+ 	newfd = open(index_lock, O_RDWR | O_CREAT | O_EXCL, 0600);
 	if (newfd < 0)
 		die("unable to create new cachefile");
 	atexit(remove_lock_file);
-	remove_lock = 1;
 
 	merge = 0;
 	for (i = 1; i < argc; i++) {
@@ -253,8 +266,12 @@ int main(int argc, char **argv)
 		}
 	}
 	if (write_cache(newfd, active_cache, active_nr) ||
-	    rename(".git/index.lock", ".git/index"))
+	    rename(index_lock, index_file))
 		die("unable to write new index file");
-	remove_lock = 0;
+
+	free(index_file);
+	free(index_lock);
+	index_lock = NULL;
+
 	return 0;
 }
update-cache.c: 0d16b36d7d074e9f0a2811a40e16e9823a628ec9
--- a/update-cache.c
+++ b/update-cache.c
@@ -270,25 +270,37 @@ static int add_cacheinfo(char *arg1, cha
 	return add_cache_entry(ce, allow_add);
 }
 
-static int remove_lock = 0;
+static char *index_lock = NULL;
 
 static void remove_lock_file(void)
 {
-	if (remove_lock)
-		unlink(".git/index.lock");
+	if (index_lock)
+		unlink(index_lock);
 }
 
 int main(int argc, char **argv)
 {
-	int i, newfd, entries;
+	int i, newfd, entries, len;
 	int allow_options = 1;
+	char *index_file, *index_path;
 
-	newfd = open(".git/index.lock", O_RDWR | O_CREAT | O_EXCL, 0600);
+	index_path = getenv(GIT_CACHE_ENVIRONMENT);
+	if (!index_path)
+		index_path = DEFAULT_GIT_CACHE_ENVIRONMENT;
+
+	len = strlen(index_path);
+	index_file = malloc(len + 7);
+	if (!index_file) error("out of memory");
+	sprintf(index_file, "%s/index", index_path);
+
+	index_lock = malloc(len + 12);
+	if (!index_lock) error("out of memory");
+	sprintf(index_lock, "%s/index.lock", index_path);
+
+	newfd = open(index_lock, O_RDWR | O_CREAT | O_EXCL, 0600);
 	if (newfd < 0)
 		die("unable to create new cachefile");
-
 	atexit(remove_lock_file);
-	remove_lock = 1;
 
 	entries = read_cache();
 	if (entries < 0)
@@ -330,9 +342,12 @@ int main(int argc, char **argv)
 			die("Unable to add %s to database", path);
 	}
 	if (write_cache(newfd, active_cache, active_nr) ||
-	    rename(".git/index.lock", ".git/index"))
+	    rename(index_lock, index_file))
 		die("Unable to write new cachefile");
 
-	remove_lock = 0;
+	free(index_file);
+	free(index_lock);
+	index_lock = NULL;
+
 	return 0;
 }

^ permalink raw reply

* [PATCH 0/3] introduce GIT_CACHE_DIRECTORY to plumbing
From: Zach Welch @ 2005-04-20  4:32 UTC (permalink / raw)
  To: git; +Cc: torvalds

The first patch introduces the GIT_CACHE_DIRECTORY to the C plumbing.
Without this patch, the index file and its lock are always placed
in './.git'.  Scripts wishing to run these commands from a different 
working directory can use this support to override the cache directory.

The second patch renames the DB_ENVIRONMENT symbols to match.  Note,
the name changes came from an off-list comment from Linus, after my
sendpatches script accidentally bombed him with a half dozen copies of
the init-db patch series summary.  His comment inspired these last two.

The third patch renames SHA1_FILE_DIRECTORY as GIT_OBJECT_DIRECTORY,
to match the "GIT_CACHE_DIRECTORY" name introduced in the first patch.
This was done last and seperately so it can be applied after a little
bit of notice.  We're not at a point of need to be backwards compatible.

This require my latest init-db cleanups be applied first, otherwise
you will get a rejection in init-db.c.

There are 3 patches in this series:
        [PATCH 1/3] add GIT_CACHE_DIRECTORY support
        [PATCH 2/3] rename object directory symbols
        [PATCH 3/3] rename SHA1_FILE_DIRECTORY

^ permalink raw reply

* Re: [RFC] Possible strategy cleanup for git add/remove/diff etc.
From: Linus Torvalds @ 2005-04-20  4:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Petr Baudis, git
In-Reply-To: <Pine.LNX.4.58.0504191846290.6467@ppc970.osdl.org>



On Tue, 19 Apr 2005, Linus Torvalds wrote:
> 
> That is indeed the whole point of the index file. In my world-view, the
> index file does _everything_. It's the staging area ("work file"), it's
> the merging area ("merge directory") and it's the cache file ("stat
> cache").
> 
> I'll immediately write a tool to diff the current working directory 
> against a tree object, and hopefully that will just make pasky happy with 
> this model too. 

Ok, "immediately" took a bit longer than I wanted to, and quite frankly,
the end result is not very well tested. It was a bit more complex than I
was hoping for to match up the index file against a tree object, since
unlike the tree<->tree comparison in diff-tree, you have to compare two
cases where the layout isn't the same.

No matter. It seems to work to a first approximation, and the result is
such a cool tool that it's worth committing and pushing out immediately. 

The code ain't exactly pretty, but hey, maybe that's just me having higher 
standards of beauty than most. Or maybe you just shudder at what I 
consider pretty in the first place, in which case you probably shouldn't 
look too closely at this one.

What the new "diff-cache" does is basically emulate "diff-tree", except 
one of the trees is always the index file.

You can also choose whether you want to trust the index file entirely
(using the "--cached" flag) or ask the diff logic to show any files that
don't match the stat state as being "tentatively changed".  Both of these
operations are very useful indeed.

For example, let's say that you have worked on your index file, and are
ready to commit. You want to see eactly _what_ you are going to commit is
without having to write a new tree object and compare it that way, and to
do that, you just do

	diff-cache --cached $(cat .git/HEAD)

(another difference between diff-tree and diff-cache is that the new 
diff-cache can take a "commit" object, and it automatically just extracts 
the tree information from there).

Example: let's say I had renamed "commit.c" to "git-commit.c", and I had 
done an "upate-cache" to make that effective in the index file. 
"show-diff" wouldn't show anything at all, since the index file matches 
my working directory. But doing a diff-cache does:

	torvalds@ppc970:~/git> diff-cache --cached $(cat .git/HEAD)
	-100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        commit.c
	+100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        git-commit.c

So what the above "diff-cache" command line does is to say

   "show me the differences between HEAD and the current index contents 
    (the ones I'd write with a "write-tree")"

And as you can see, the output matches "diff-tree -r" output (we always do
"-r", since the index is always fully populated). All the same rules: "+"  
means added file, "-" means removed file, and "*" means changed file. You 
can trivially see that the above is a rename.

In fact, "diff-tree --cached" _should_ always be entirely equivalent to
actually doing a "write-tree" and comparing that. Except this one is much
nicer for the case where you just want to check. Maybe you don't want to
do the tree.

So doing a "diff-cache --cached" is basically very useful when you are 
asking yourself "what have I already marked for being committed, and 
what's the difference to a previous tree".

However, the "non-cached" version takes a different approach, and is
potentially the even more useful of the two in that what it does can't be
emulated with a "write-tree + diff-tree". Thus that's the default mode.  
The non-cached version asks the question

   "show me the differences between HEAD and the currently checked out 
    tree - index contents _and_ files that aren't up-to-date"

which is obviously a very useful question too, since that tells you what
you _could_ commit. Again, the output matches the "diff-tree -r" output to
a tee, but with a twist.

The twist is that if some file doesn't match the cache, we don't have a
backing store thing for it, and we use the magic "all-zero" sha1 to show
that. So let's say that you have edited "kernel/sched.c", but have not
actually done an update-cache on it yet - there is no "object" associated
with the new state, and you get:

	torvalds@ppc970:~/v2.6/linux> diff-cache $(cat .git/HEAD )
	*100644->100664 blob    7476bbcfe5ef5a1dd87d745f298b831143e4d77e->0000000000000000000000000000000000000000      kernel/sched.c

ie it shows that the tree has changed, and that "kernel/sched.c" has is
not up-to-date and may contain new stuff. The all-zero sha1 means that to
get the real diff, you need to look at the object in the working directory
directly rather than do an object-to-object diff.

NOTE! As with other commands of this type, "diff-cache" does not actually 
look at the contents of the file at all. So maybe "kernel/sched.c" hasn't 
actually changed, and it's just that you touched it. In either case, it's 
a note that you need to upate-cache it to make the cache be in sync.

NOTE 2! You can have a mixture of files show up as "has been updated" and
"is still dirty in the working directory" together. You can always tell
which file is in which state, since the "has been updated" ones show a
valid sha1, and the "not in sync with the index" ones will always have the
special all-zero sha1.

I think this should obviate the need for Pasky keeping a separate work 
file. You can always tell what the difference to the last commit is with 
this, and you don't need to have a separate file to tell you about what 
you're supposed to do.

			Linus

^ permalink raw reply

* [PATCH 3/3] init-db.c: create and use safe_create_dir helper
From: Zach Welch @ 2005-04-20  4:28 UTC (permalink / raw)
  To: git; +Cc: torvalds

This patch applies on top of:
        [PATCH 1/3] init-db.c: cleanup comments
        [PATCH 2/3] init-db.c: normalize env var handling.

 init-db.c |   30 ++++++++++++++----------------
 1 files changed, 14 insertions(+), 16 deletions(-)

Signed-Off-By: Zach Welch <zw@superlucidity.net>

Factor mkdir calls into common safe_create_dir subroutine.

--- a/init-db.c	2005-04-19 18:50:14.000000000 -0700
+++ b/init-db.c	2005-04-19 18:45:48.000000000 -0700
@@ -5,6 +5,16 @@
  */
 #include "cache.h"
 
+void safe_create_dir(char *dir)
+{
+	if (mkdir(dir, 0755) < 0) {
+		if (errno != EEXIST) {
+			perror(dir);
+			exit(1);
+		}
+	}
+}
+
 /*
  * If you want to, you can share the DB area with any number of branches.
  * That has advantages: you can save space by sharing all the SHA1 objects.
@@ -16,10 +26,7 @@
 	char *sha1_dir, *path;
 	int len, i;
 
-	if (mkdir(".git", 0755) < 0) {
-		perror("unable to create .git directory");
-		exit(1);
-	}
+	safe_create_dir(".git");
 
 	sha1_dir = getenv(DB_ENVIRONMENT);
 	if (!sha1_dir) {
@@ -27,22 +34,13 @@
 		fprintf(stderr, "defaulting to local storage area\n");
 	}
 	len = strlen(sha1_dir);
-	if (mkdir(sha1_dir, 0755) < 0) {
-		if (errno != EEXIST) {
-			perror(sha1_dir);
-			exit(1);
-		}
-	}
 	path = malloc(len + 40);
 	memcpy(path, sha1_dir, len);
+
+	safe_create_dir(sha1_dir);
 	for (i = 0; i < 256; i++) {
 		sprintf(path+len, "/%02x", i);
-		if (mkdir(path, 0755) < 0) {
-			if (errno != EEXIST) {
-				perror(path);
-				exit(1);
-			}
-		}
+		safe_create_dir(path);
 	}
 	return 0;
 }

^ permalink raw reply

* [PATCH 2/3] init-db.c: normalize env var handling.
From: Zach Welch @ 2005-04-20  4:28 UTC (permalink / raw)
  To: git; +Cc: torvalds

This patch applies on top of:
        [PATCH 1/3] init-db.c: cleanup comments

 init-db.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

Signed-Off-By: Zach Welch <zw@superlucidity.net>

Normalize init-db environment variable handling, allowing the creation
of object directories with something other than DEFAULT_DB_ENVIRONMENT.

--- a/init-db.c
+++ b/init-db.c
@@ -22,15 +22,10 @@ int main(int argc, char **argv)
 	}
 
 	sha1_dir = getenv(DB_ENVIRONMENT);
-	if (sha1_dir) {
-		struct stat st;
-		if (!stat(sha1_dir, &st) && S_ISDIR(st.st_mode))
-			return 0;
-		fprintf(stderr, "DB_ENVIRONMENT set to bad directory %s: ", sha1_dir);
+	if (!sha1_dir) {
+		sha1_dir = DEFAULT_DB_ENVIRONMENT;
+		fprintf(stderr, "defaulting to local storage area\n");
 	}
-
-	sha1_dir = DEFAULT_DB_ENVIRONMENT;
-	fprintf(stderr, "defaulting to private storage area\n");
 	len = strlen(sha1_dir);
 	if (mkdir(sha1_dir, 0755) < 0) {
 		if (errno != EEXIST) {

^ permalink raw reply

* [PATCH 1/3] init-db.c: cleanup comments
From: Zach Welch @ 2005-04-20  4:28 UTC (permalink / raw)
  To: git; +Cc: torvalds

 init-db.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

Signed-Off-By: Zach Welch <zw@superlucidity.net>

Consolidate comments at top of main.

--- a/init-db.c
+++ b/init-db.c
@@ -5,6 +5,12 @@
  */
 #include "cache.h"
 
+/*
+ * If you want to, you can share the DB area with any number of branches.
+ * That has advantages: you can save space by sharing all the SHA1 objects.
+ * On the other hand, it might just make lookup slower and messier. You
+ * be the judge.  The default case is to have one DB per managed directory.
+ */
 int main(int argc, char **argv)
 {
 	char *sha1_dir, *path;
@@ -15,12 +21,6 @@ int main(int argc, char **argv)
 		exit(1);
 	}
 
-	/*
-	 * If you want to, you can share the DB area with any number of branches.
-	 * That has advantages: you can save space by sharing all the SHA1 objects.
-	 * On the other hand, it might just make lookup slower and messier. You
-	 * be the judge.
-	 */
 	sha1_dir = getenv(DB_ENVIRONMENT);
 	if (sha1_dir) {
 		struct stat st;
@@ -29,9 +29,6 @@ int main(int argc, char **argv)
 		fprintf(stderr, "DB_ENVIRONMENT set to bad directory %s: ", sha1_dir);
 	}
 
-	/*
-	 * The default case is to have a DB per managed directory.
-	 */
 	sha1_dir = DEFAULT_DB_ENVIRONMENT;
 	fprintf(stderr, "defaulting to private storage area\n");
 	len = strlen(sha1_dir);

^ permalink raw reply

* [PATCH 0/3] init-db.c cleanup and fixes
From: Zach Welch @ 2005-04-20  4:28 UTC (permalink / raw)
  To: git; +Cc: torvalds

Linus,

I see you pulled the first two patches of my last series into your tree, 
so I know I had your attention briefly. I wanted to see what I can do to
help the rest of the changes get in, so....

I realized last night as I was going to bed that the third patch might 
not be accepted because it changes the behaviour slightly, nevermind that 
they were - by comparison with today's alternative - plain ugly.  

For what it's worth, init-db is practically useless for my package 
without the second change in this series.  Currently, I've implemented 
init-db in pure perl, but I'd like to use init-db.

As such, I started from scratch, and came up with a much simpler 
series of patches.  Please continue to ignore the previous series, but
consider these new patches in their stead.

New GIT_FILE_DIRECTORY patches will follow seperately.

Cheers,

Zach Welch
Superlucidity Services

These patches were based off commit 4e1778c8ceeaea340a2a7f62fc65736da327ec05.

There are 3 patches in this series:
        [PATCH 1/3] init-db.c: cleanup comments
        [PATCH 2/3] init-db.c: normalize env var handling.
        [PATCH 3/3] init-db.c: create and use safe_create_dir helper

^ permalink raw reply

* Re: wit 0.0.3 - a web interface for git available
From: Greg KH @ 2005-04-20  4:18 UTC (permalink / raw)
  To: Christian Meder; +Cc: git
In-Reply-To: <1113956951.3309.22.camel@localhost>

On Wed, Apr 20, 2005 at 02:29:11AM +0200, Christian Meder wrote:
> Hi,
> 
> ok it's starting to look like spam ;-)
> 
> I uploaded a new version of wit to http://www.absolutegiganten.org/wit

Why not work together with Kay's tool:
	http://ehlo.org/~kay/gitweb.pl?project=linux-2.6&action=show_log


Thanks,

greg k-h

^ permalink raw reply

* Re: [script] ge: export commits as patches
From: David A. Wheeler @ 2005-04-20  2:34 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Ingo Molnar, git
In-Reply-To: <20050419194108.GN12757@pasky.ji.cz>

Forget my earlier "aspatch" proposal, that's a lousy name.

How about "mkpatch"?  Seems like a reasonable name for
a command that makes a patch.  GNU Arch uses that command name.
CVS & Subversion basically do this as part of "diff"
(which is another possibility).

--- David A. Wheeler

^ 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