Git development
 help / color / mirror / Atom feed
* [PATCH 11/19] migrate write-tree.c to use the new cache api's
From: Brad Roberts @ 2005-04-21 18:37 UTC (permalink / raw)
  To: git

tree 3a2928786f84d81cfb1a5846cdaf9f3d5403cbcf
parent a94803645fb68119be8835d466585c91e664a173
author Brad Roberts <braddr@puremagic.com> 1114077713 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114077713 -0700

[PATCH] migrate write-tree.c to use the new cache api's

Along the way, altered the write_tree recursion to stay based off of a starting
position rather than moving the array pointer for each recurse step.

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

 write-tree.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

Index: write-tree.c
===================================================================
--- a94803645fb68119be8835d466585c91e664a173:1/write-tree.c  (mode:100644 sha1:827809dbddbff6dd8cf842641f6db5ad2f3ae07a)
+++ 8a4556bdf5bc847117c840a8fd7fa42f6efb16e1:1/write-tree.c  (mode:100644 sha1:f1b12cdde1bb446a134a121760007150008b251a)
@@ -29,7 +29,7 @@
 
 #define ORIG_OFFSET (40)	/* Enough space to add the header of "tree <size>\0" */
 
-static int write_tree(struct cache_entry **cachep, int maxentries, const char *base, int baselen, unsigned char *returnsha1)
+static int write_tree(int start_pos, const char *base, int baselen, unsigned char *returnsha1)
 {
 	unsigned char subdir_sha1[20];
 	unsigned long size, offset;
@@ -43,7 +43,7 @@
 
 	nr = 0;
 	do {
-		struct cache_entry *ce = cachep[nr];
+		struct cache_entry *ce = get_cache_entry(start_pos + nr);
 		const char *pathname = ce->name, *filename, *dirname;
 		int pathlen = ce_namelen(ce), entrylen;
 		unsigned char *sha1;
@@ -53,16 +53,13 @@
 		if (baselen >= pathlen || memcmp(base, pathname, baselen))
 			break;
 
-		sha1 = ce->sha1;
-		mode = ntohl(ce->ce_mode);
-
 		/* Do we have _further_ subdirectories? */
 		filename = pathname + baselen;
 		dirname = strchr(filename, '/');
 		if (dirname) {
 			int subdir_written;
 
-			subdir_written = write_tree(cachep + nr, maxentries - nr, pathname, dirname-pathname+1, subdir_sha1);
+			subdir_written = write_tree(start_pos + nr, pathname, dirname-pathname+1, subdir_sha1);
 			nr += subdir_written;
 
 			/* Now we need to write out the directory entry into this tree.. */
@@ -72,6 +69,9 @@
 			/* ..but the directory entry doesn't count towards the total count */
 			nr--;
 			sha1 = subdir_sha1;
+		} else {
+			sha1 = ce->sha1;
+			mode = ntohl(ce->ce_mode);
 		}
 
 		if (check_valid_sha1(sha1) < 0)
@@ -87,7 +87,7 @@
 		memcpy(buffer + offset, sha1, 20);
 		offset += 20;
 		nr++;
-	} while (nr < maxentries);
+	} while ((start_pos + nr) < get_num_cache_entries());
 
 	i = prepend_integer(buffer, offset - ORIG_OFFSET, ORIG_OFFSET);
 	i -= 5;
@@ -110,7 +110,7 @@
 	/* Verify that the tree is merged */
 	unmerged = 0;
 	for (i = 0; i < entries; i++) {
-		struct cache_entry *ce = active_cache[i];
+		struct cache_entry *ce = get_cache_entry(i);
 		if (ntohs(ce->ce_flags) & ~CE_NAMEMASK) {
 			if (++unmerged > 10) {
 				fprintf(stderr, "...\n");
@@ -123,7 +123,7 @@
 		die("write-tree: not able to write tree");
 
 	/* Ok, write it out */
-	if (write_tree(active_cache, entries, "", 0, sha1) != entries)
+	if (write_tree(0, "", 0, sha1) != entries)
 		die("write-tree: internal error");
 	printf("%s\n", sha1_to_hex(sha1));
 	return 0;


^ permalink raw reply

* [PATCH 10/19] migrate check-files.c to the new cache api's
From: Brad Roberts @ 2005-04-21 18:36 UTC (permalink / raw)
  To: git

tree 54aca1a1c5f41995c79fdf6b5f720574d0bfd8ef
parent 50a6596bf7f51ecd598cd02d9c44379a9b92044a
author Brad Roberts <braddr@puremagic.com> 1114077105 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114077105 -0700

[PATCH] migrate check-files.c to the new cache api's

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

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

Index: check-files.c
===================================================================
--- 50a6596bf7f51ecd598cd02d9c44379a9b92044a:1/check-files.c  (mode:100644 sha1:7d16691aa9d51b5b4670d5837b3527ee7c7da79c)
+++ a94803645fb68119be8835d466585c91e664a173:1/check-files.c  (mode:100644 sha1:919e418b5f0f85220445c876a37bf4cf61d26525)
@@ -26,7 +26,7 @@
 	pos = cache_name_pos(path, strlen(path));
 	if (pos < 0)
 		die("preparing to update existing file '%s' not in cache", path);
-	ce = active_cache[pos];
+	ce = get_cache_entry(pos);
 
 	if (fstat(fd, &st) < 0)
 		die("fstat(%s): %s", path, strerror(errno));


^ permalink raw reply

* [PATCH 09/19] migrate read-tree.c to the new cache api's
From: Brad Roberts @ 2005-04-21 18:36 UTC (permalink / raw)
  To: git

tree 7a3cab4437a849857cc899017b97eea1787a6ce1
parent 099367f98cc063c33733d15c7a2d9737bea853d9
author Brad Roberts <braddr@puremagic.com> 1114077044 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114077044 -0700

[PATCH] migrate read-tree.c to the new cache api's

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

 read-tree.c |   52 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 31 insertions(+), 21 deletions(-)

Index: read-tree.c
===================================================================
--- 099367f98cc063c33733d15c7a2d9737bea853d9:1/read-tree.c  (mode:100644 sha1:4ad48f5c409ead69407d2b5feab4466cdcb499f8)
+++ 50a6596bf7f51ecd598cd02d9c44379a9b92044a:1/read-tree.c  (mode:100644 sha1:ad9128f26613a82361475516dd0f2b470f4ce4b3)
@@ -146,26 +146,30 @@
 	return NULL;
 }
 
-static void trivially_merge_cache(struct cache_entry **src, int nr)
+/* rather than doing the 'right' thing of deleting entries as we merge,
+ * walk dst through the cache, overwriting entries as we go and at the
+ * end truncate the size of the cache */
+static void trivially_merge_cache()
 {
 	static struct cache_entry null_entry;
-	struct cache_entry **dst = src;
 	struct cache_entry *old = &null_entry;
+	int src = 0, dst = 0, nr = get_num_cache_entries();
 
-	while (nr) {
+	while (src < nr) {
 		struct cache_entry *ce, *result;
 
-		ce = src[0];
+		ce = get_cache_entry(src);
 
 		/* We throw away original cache entries except for the stat information */
 		if (!ce_stage(ce)) {
 			old = ce;
 			src++;
-			nr--;
-			active_nr--;
 			continue;
 		}
-		if (nr > 2 && (result = merge_entries(ce, src[1], src[2])) != NULL) {
+		if ((src < (nr - 2)) &&
+		    (result = merge_entries(ce,
+					    get_cache_entry(src + 1),
+					    get_cache_entry(src + 2))) != NULL) {
 			/*
 			 * See if we can re-use the old CE directly?
 			 * That way we get the uptodate stat info.
@@ -175,40 +179,46 @@
 			ce = result;
 			ce->ce_flags &= ~htons(CE_STAGEMASK);
 			src += 2;
-			nr -= 2;
-			active_nr -= 2;
 		}
-		*dst++ = ce;
+		set_cache_entry(ce, dst);
+		dst++;
 		src++;
+	}
+	/* this could be replaced by a truncate api */
+	while (nr > dst) {
 		nr--;
+		remove_cache_entry_at(nr);
 	}
 }
 
-static void merge_stat_info(struct cache_entry **src, int nr)
+static void merge_stat_info()
 {
 	static struct cache_entry null_entry;
-	struct cache_entry **dst = src;
 	struct cache_entry *old = &null_entry;
+	int src = 0, dst = 0, nr = get_num_cache_entries();
 
-	while (nr) {
+	while (src < nr) {
 		struct cache_entry *ce;
 
-		ce = src[0];
+		ce = get_cache_entry(src);
 
 		/* We throw away original cache entries except for the stat information */
 		if (!ce_stage(ce)) {
 			old = ce;
 			src++;
-			nr--;
-			active_nr--;
 			continue;
 		}
 		if (path_matches(ce, old) && same(ce, old))
 			*ce = *old;
 		ce->ce_flags &= ~htons(CE_STAGEMASK);
-		*dst++ = ce;
+		set_cache_entry(ce, dst);
+		dst++;
 		src++;
+	}
+	/* this could be replaced by a truncate api */
+	while (nr > dst) {
 		nr--;
+		remove_cache_entry_at(nr);
 	}
 }
 
@@ -233,8 +243,8 @@
 			if (stage)
 				usage("-m needs to come first");
 			read_cache();
-			for (i = 0; i < active_nr; i++) {
-				if (ce_stage(active_cache[i]))
+			for (i = 0; i < get_num_cache_entries(); i++) {
+				if (ce_stage(get_cache_entry(i)))
 					usage("you need to resolve your current index first");
 			}
 			stage = 1;
@@ -252,10 +262,10 @@
 	if (merge) {
 		switch (stage) {
 		case 4:	/* Three-way merge */
-			trivially_merge_cache(active_cache, active_nr);
+			trivially_merge_cache();
 			break;
 		case 2:	/* Just read a tree, merge with old cache contents */
-			merge_stat_info(active_cache, active_nr);
+			merge_stat_info();
 			break;
 		default:
 			die("just how do you expect me to merge %d trees?", stage-1);


^ permalink raw reply

* [PATCH 08/19] rename remove_entry_at to remove_cache_entry_at and expose as a public api
From: Brad Roberts @ 2005-04-21 18:36 UTC (permalink / raw)
  To: git

tree 68af3fb1d46759f437d15f310a9aea2931708601
parent e2acfff5e544a8c6769a9e665927092b3edd7579
author Brad Roberts <braddr@puremagic.com> 1114075605 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114075605 -0700

[PATCH] rename remove_entry_at to remove_cache_entry_at and expose as a public api

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

 cache.h      |    1 +
 read-cache.c |    6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

Index: cache.h
===================================================================
--- e2acfff5e544a8c6769a9e665927092b3edd7579:1/cache.h  (mode:100644 sha1:9ad6e805eafcb213c6bb4b1f8ff4d4e053fa6067)
+++ 099367f98cc063c33733d15c7a2d9737bea853d9:1/cache.h  (mode:100644 sha1:74d816c34245e0dde41643188f38cf99ca75e75f)
@@ -96,6 +96,7 @@
 extern int get_num_cache_entries();
 extern struct cache_entry * get_cache_entry(int pos);
 extern void set_cache_entry(struct cache_entry *ce, int pos);
+extern int remove_cache_entry_at(int pos);
 
 #define MTIME_CHANGED	0x0001
 #define CTIME_CHANGED	0x0002
Index: read-cache.c
===================================================================
--- e2acfff5e544a8c6769a9e665927092b3edd7579:1/read-cache.c  (mode:100644 sha1:8eaa05957a481b09116c37e43e16c5ef4e219a1e)
+++ 099367f98cc063c33733d15c7a2d9737bea853d9:1/read-cache.c  (mode:100644 sha1:286f7136bc164f3a2317bb492138d9221efb4025)
@@ -87,7 +87,7 @@
 }
 
 /* Remove entry, return true if there are more entries to go.. */
-static int remove_entry_at(int pos)
+int remove_cache_entry_at(int pos)
 {
 	active_nr--;
 	if (pos >= active_nr)
@@ -100,7 +100,7 @@
 {
 	int pos = cache_name_pos(path, strlen(path));
 	if (pos >= 0)
-		remove_entry_at(pos);
+		remove_cache_entry_at(pos);
 	return 0;
 }
 
@@ -148,7 +148,7 @@
 	if (pos < active_nr && ce_stage(ce) == 0) {
 		while (same_name(active_cache[pos], ce)) {
 			ok_to_add = 1;
-			if (!remove_entry_at(pos))
+			if (!remove_cache_entry_at(pos))
 				break;
 		}
 	}


^ permalink raw reply

* [PATCH 07/19] migrate merge-cache.c over to the new cache api's
From: Brad Roberts @ 2005-04-21 18:36 UTC (permalink / raw)
  To: git

tree 8140acee0f9c57bfd87f40d1f99242c772afcdf2
parent 32efd81a3292a923ce5b5ae2e39ffefd0b08664d
author Brad Roberts <braddr@puremagic.com> 1114074631 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114074631 -0700

[PATCH] migrate merge-cache.c over to the new cache api's

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

 merge-cache.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

Index: merge-cache.c
===================================================================
--- 32efd81a3292a923ce5b5ae2e39ffefd0b08664d:1/merge-cache.c  (mode:100644 sha1:35a0d588178aa5371399458b1a15519cffd645b8)
+++ e2acfff5e544a8c6769a9e665927092b3edd7579:1/merge-cache.c  (mode:100644 sha1:c2f96e7652a2aea9417c3790bfe9ab14ffcdb12f)
@@ -30,7 +30,7 @@
 {
 	int found;
 	
-	if (pos >= active_nr)
+	if (pos >= get_num_cache_entries())
 		die("merge-cache: %s not in the cache", path);
 	arguments[0] = pgm;
 	arguments[1] = "";
@@ -40,7 +40,7 @@
 	found = 0;
 	do {
 		static char hexbuf[4][60];
-		struct cache_entry *ce = active_cache[pos];
+		struct cache_entry *ce = get_cache_entry(pos);
 		int stage = ce_stage(ce);
 
 		if (strcmp(ce->name, path))
@@ -48,7 +48,7 @@
 		found++;
 		strcpy(hexbuf[stage], sha1_to_hex(ce->sha1));
 		arguments[stage] = hexbuf[stage];
-	} while (++pos < active_nr);
+	} while (++pos < get_num_cache_entries());
 	if (!found)
 		die("merge-cache: %s not in the cache", path);
 	run_program();
@@ -70,8 +70,8 @@
 static void merge_all(void)
 {
 	int i;
-	for (i = 0; i < active_nr; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < get_num_cache_entries(); i++) {
+		struct cache_entry *ce = get_cache_entry(i);
 		if (!ce_stage(ce))
 			continue;
 		i += merge_entry(i, ce->name)-1;


^ permalink raw reply

* [PATCH 06/19] migrate show-files.c to the new cache api's
From: Brad Roberts @ 2005-04-21 18:35 UTC (permalink / raw)
  To: git

tree a3bd48d2beba79d70e97d8647ee35a645e494350
parent f908b2542a9a3ea321633a31cf0e7ca2c8b669d4
author Brad Roberts <braddr@puremagic.com> 1114074486 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114074486 -0700

[PATCH] migrate show-files.c to the new cache api's

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

 show-files.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Index: show-files.c
===================================================================
--- f908b2542a9a3ea321633a31cf0e7ca2c8b669d4:1/show-files.c  (mode:100644 sha1:0b49ca051de413e7182445dd8fb9144125716974)
+++ 32efd81a3292a923ce5b5ae2e39ffefd0b08664d:1/show-files.c  (mode:100644 sha1:11fbbccef2df50d528105ceb48b15275f2a5693e)
@@ -116,8 +116,8 @@
 			printf("%s%s%c", tag_other, dir[i], line_terminator);
 	}
 	if (show_cached | show_stage) {
-		for (i = 0; i < active_nr; i++) {
-			struct cache_entry *ce = active_cache[i];
+		for (i = 0; i < get_num_cache_entries(); i++) {
+			struct cache_entry *ce = get_cache_entry(i);
 			if (show_unmerged && !ce_stage(ce))
 				continue;
 			if (!show_stage)
@@ -136,8 +136,8 @@
 		}
 	}
 	if (show_deleted) {
-		for (i = 0; i < active_nr; i++) {
-			struct cache_entry *ce = active_cache[i];
+		for (i = 0; i < get_num_cache_entries(); i++) {
+			struct cache_entry *ce = get_cache_entry(i);
 			struct stat st;
 			if (!stat(ce->name, &st))
 				continue;


^ permalink raw reply

* Re: "GIT_INDEX_FILE" environment variable
From: Linus Torvalds @ 2005-04-21 18:37 UTC (permalink / raw)
  To: Git Mailing List
In-Reply-To: <Pine.LNX.4.58.0504211100330.2344@ppc970.osdl.org>



On Thu, 21 Apr 2005, Linus Torvalds wrote:
> 
> You can also use it to test merges without screwing up your old index file 
> in case something goes wrong.

Btw, if it wasn't obvious, for the merge thing to work you need to first
copy the old index file _or_ generate a new temporary index file first, so
that doing the three-way merge has a previous index file to work with. Ie
it would look something like

	cp .git/index .tmp-index
	GIT_INDEX_FILE=.tmp-index read-tree -m $orig $branch1 $branch2

but this same approach can also be used to merge things _without_ actually
having any specific version checked out, in which case it would just be

	GIT_INDEX_FILE=.tmp-index read-tree $orig
	GIT_INDEX_FILE=.tmp-index read-tree -m $orig $branch1 $branch2

which allows you to create a merged index file that is totally independent 
on whatever (if anything) you happen to be working on right now.

Together with a SHA1_FILE_DIRECTORY, it allows you to do merges entirely
outside any real git tree, and without any other setup. That's quite nice
for the case where your actual working tree may be dirty, and you don't
want to mess around in it.

			Linus

^ permalink raw reply

* [PATCH 05/19] migrate checkout-cache.c to the new cache api's
From: Brad Roberts @ 2005-04-21 18:35 UTC (permalink / raw)
  To: git

tree b95df78e4cc90db8c4c8d0ad870bef74b7fd29e2
parent 40bf732f5bcb986943070a2ed6c09a16543d81be
author Brad Roberts <braddr@puremagic.com> 1114074234 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114074234 -0700

[PATCH] migrate checkout-cache.c to the new cache api's

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

 checkout-cache.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Index: checkout-cache.c
===================================================================
--- 40bf732f5bcb986943070a2ed6c09a16543d81be:1/checkout-cache.c  (mode:100644 sha1:8bf86016b5d5fd88a52ce694fc59bb9ecb550d22)
+++ f908b2542a9a3ea321633a31cf0e7ca2c8b669d4:1/checkout-cache.c  (mode:100644 sha1:bf9cd0572c883219d37f2788ec5f5553a136df2b)
@@ -128,15 +128,15 @@
 			fprintf(stderr, "checkout-cache: %s is not in the cache\n", name);
 		return -1;
 	}
-	return checkout_entry(active_cache[pos]);
+	return checkout_entry(get_cache_entry(pos));
 }
 
 static int checkout_all(void)
 {
 	int i;
 
-	for (i = 0; i < active_nr ; i++) {
-		struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < get_num_cache_entries() ; i++) {
+		struct cache_entry *ce = get_cache_entry(i);
 		if (ce_stage(ce))
 			continue;
 		if (checkout_entry(ce) < 0)


^ permalink raw reply

* [PATCH 04/19] Migrate update-cache.c to use the new cache api's
From: Brad Roberts @ 2005-04-21 18:35 UTC (permalink / raw)
  To: git

tree 34f7fc89e28a40387e811057065592ed2f0218a2
parent d70686e08f453199e5451b27fc7d0b36b73a5c7f
author Brad Roberts <braddr@puremagic.com> 1114073784 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114073784 -0700

[PATCH] Migrate update-cache.c to use the new cache api's

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

 read-cache.c   |    3 +++
 update-cache.c |   13 +++++--------
 2 files changed, 8 insertions(+), 8 deletions(-)

Index: read-cache.c
===================================================================
--- d70686e08f453199e5451b27fc7d0b36b73a5c7f:1/read-cache.c  (mode:100644 sha1:6689df59d5a93e0503d7c80c114efbd16de826f3)
+++ 40bf732f5bcb986943070a2ed6c09a16543d81be:1/read-cache.c  (mode:100644 sha1:8eaa05957a481b09116c37e43e16c5ef4e219a1e)
@@ -122,6 +122,9 @@
 
 void set_cache_entry(struct cache_entry *ce, int pos)
 {
+	/* You can NOT just free active_cache[i] here, since it
+	 * might not be necessarily malloc()ed but can also come
+	 * from mmap(). */
 	active_cache[pos] = ce;
 }
 
Index: update-cache.c
===================================================================
--- d70686e08f453199e5451b27fc7d0b36b73a5c7f:1/update-cache.c  (mode:100644 sha1:585951108c57a64bb774114d289d81fd7fd22768)
+++ 40bf732f5bcb986943070a2ed6c09a16543d81be:1/update-cache.c  (mode:100644 sha1:e741f593eb9c56c596fabed7eb6b79dee2d8cba9)
@@ -204,13 +204,13 @@
 {
 	int i;
 
-	for (i = 0; i < active_nr; i++) {
+	for (i = 0; i < get_num_cache_entries(); i++) {
 		struct cache_entry *ce, *new;
-		ce = active_cache[i];
+		ce = get_cache_entry(i);
 		if (ce_stage(ce)) {
 			printf("%s: needs merge\n", ce->name);
-			while ((i < active_nr) &&
-			       ! strcmp(active_cache[i]->name, ce->name))
+			while ((i < get_num_cache_entries()) &&
+			       ! strcmp(get_cache_entry(i)->name, ce->name))
 				i++;
 			i--;
 			continue;
@@ -221,10 +221,7 @@
 			printf("%s: needs update\n", ce->name);
 			continue;
 		}
-		/* You can NOT just free active_cache[i] here, since it
-		 * might not be necessarily malloc()ed but can also come
-		 * from mmap(). */
-		active_cache[i] = new;
+		set_cache_entry(new, i);
 	}
 }
 


^ permalink raw reply

* [PATCH 03/19] convert show-diff.c to use new cache hiding api's
From: Brad Roberts @ 2005-04-21 18:35 UTC (permalink / raw)
  To: git

tree bbc50100a5cfd22264c2b0731ef8678656a399d8
parent 27fc41dcd4aecafdaf583f3962697a2fa3fb6480
author Brad Roberts <braddr@puremagic.com> 1114073516 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114073516 -0700

[PATCH] convert show-diff.c to use new cache hiding api's

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

 show-diff.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Index: show-diff.c
===================================================================
--- 27fc41dcd4aecafdaf583f3962697a2fa3fb6480:1/show-diff.c  (mode:100644 sha1:da364e26e28823f951a6be1b686a458575f28ea1)
+++ d70686e08f453199e5451b27fc7d0b36b73a5c7f:1/show-diff.c  (mode:100644 sha1:e2642b65805b3e52a16c6309b44a92c2a2bd13c3)
@@ -154,7 +154,7 @@
 	prepare_diff_cmd();
 	for (i = 0; i < entries; i++) {
 		struct stat st;
-		struct cache_entry *ce = active_cache[i];
+		struct cache_entry *ce = get_cache_entry(i);
 		int changed;
 		unsigned long size;
 		char type[20];
@@ -172,7 +172,7 @@
 				printf("%s: Unmerged\n",
 				       ce->name);
 			while (i < entries &&
-			       !strcmp(ce->name, active_cache[i]->name))
+			       !strcmp(ce->name, get_cache_entry(i)->name))
 				i++;
 			i--; /* compensate for loop control increments */
 			continue;


^ permalink raw reply

* [PATCH 02/19] Add new api's to front the active_cache and active_nr cache internals
From: Brad Roberts @ 2005-04-21 18:34 UTC (permalink / raw)
  To: git

tree ebbf2c037e68116c4ff934f140ca12cdbe13311d
parent 77de9e0b7a81ddc22526c9415f0273171f631d3f
author Brad Roberts <braddr@puremagic.com> 1114073146 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114073146 -0700

[PATCH] Add new api's to front the active_cache and active_nr cache internals

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

 cache.h      |    3 +++
 read-cache.c |   15 +++++++++++++++
 2 files changed, 18 insertions(+)

Index: cache.h
===================================================================
--- 77de9e0b7a81ddc22526c9415f0273171f631d3f:1/cache.h  (mode:100644 sha1:a101870e4a002a2548d88544a77bedad21668203)
+++ 27fc41dcd4aecafdaf583f3962697a2fa3fb6480:1/cache.h  (mode:100644 sha1:9ad6e805eafcb213c6bb4b1f8ff4d4e053fa6067)
@@ -93,6 +93,9 @@
 extern int add_cache_entry(struct cache_entry *ce, int ok_to_add);
 extern int remove_file_from_cache(char *path);
 extern int cache_match_stat(struct cache_entry *ce, struct stat *st);
+extern int get_num_cache_entries();
+extern struct cache_entry * get_cache_entry(int pos);
+extern void set_cache_entry(struct cache_entry *ce, int pos);
 
 #define MTIME_CHANGED	0x0001
 #define CTIME_CHANGED	0x0002
Index: read-cache.c
===================================================================
--- 77de9e0b7a81ddc22526c9415f0273171f631d3f:1/read-cache.c  (mode:100644 sha1:349ebd1f8a0a95bf462bb1dfd3d9dfb50628829c)
+++ 27fc41dcd4aecafdaf583f3962697a2fa3fb6480:1/read-cache.c  (mode:100644 sha1:6689df59d5a93e0503d7c80c114efbd16de826f3)
@@ -110,6 +110,21 @@
 	return ce_namelen(b) == len && !memcmp(a->name, b->name, len);
 }
 
+int get_num_cache_entries()
+{
+	return active_nr;
+}
+
+struct cache_entry * get_cache_entry(int pos)
+{
+	return active_cache[pos];
+}
+
+void set_cache_entry(struct cache_entry *ce, int pos)
+{
+	active_cache[pos] = ce;
+}
+
 int add_cache_entry(struct cache_entry *ce, int ok_to_add)
 {
 	int pos;


^ permalink raw reply

* [PATCH 01/19] write_cache api signature change, isolate active_cache and active_nr inside read-cache.c
From: Brad Roberts @ 2005-04-21 18:34 UTC (permalink / raw)
  To: git

tree f45fd10b26bf98349b63427805a96bd0551cad74
parent 43fdf65356c50483233cb3d6e391b0849b2a2a50
parent cd1c034369b73da7503da365fa556aab27004814
author Brad Roberts <braddr@puremagic.com> 1114072582 -0700
committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114072582 -0700

[PATCH] write_cache api signature change, isolate active_cache and active_nr inside read-cache.c


Signed-off-by: Brad Roberts <braddr@puremagic.com>
---

 cache.h        |    2 +-
 read-cache.c   |    8 ++++----
 read-tree.c    |    2 +-
 update-cache.c |    2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

Index: cache.h
===================================================================
--- cd1c034369b73da7503da365fa556aab27004814:1/cache.h  (mode:100644 sha1:828d660ab82bb35a1ca632a2ba4620dc483889bd)
+++ 77de9e0b7a81ddc22526c9415f0273171f631d3f:1/cache.h  (mode:100644 sha1:a101870e4a002a2548d88544a77bedad21668203)
@@ -88,7 +88,7 @@
 
 /* Initialize and use the cache information */
 extern int read_cache(void);
-extern int write_cache(int newfd, struct cache_entry **cache, int entries);
+extern int write_cache(int newfd);
 extern int cache_name_pos(const char *name, int namelen);
 extern int add_cache_entry(struct cache_entry *ce, int ok_to_add);
 extern int remove_file_from_cache(char *path);
Index: read-cache.c
===================================================================
--- cd1c034369b73da7503da365fa556aab27004814:1/read-cache.c  (mode:100644 sha1:2f6a4aa18d48865db80459a3459ac4384b0b16c8)
+++ 77de9e0b7a81ddc22526c9415f0273171f631d3f:1/read-cache.c  (mode:100644 sha1:349ebd1f8a0a95bf462bb1dfd3d9dfb50628829c)
@@ -267,7 +267,7 @@
 	return 0;
 }
 
-int write_cache(int newfd, struct cache_entry **cache, int entries)
+int write_cache(int newfd)
 {
 	SHA_CTX c;
 	struct cache_header hdr;
@@ -275,14 +275,14 @@
 
 	hdr.hdr_signature = htonl(CACHE_SIGNATURE);
 	hdr.hdr_version = htonl(2);
-	hdr.hdr_entries = htonl(entries);
+	hdr.hdr_entries = htonl(active_nr);
 
 	SHA1_Init(&c);
 	if (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)
 		return -1;
 
-	for (i = 0; i < entries; i++) {
-		struct cache_entry *ce = cache[i];
+	for (i = 0; i < active_nr; i++) {
+		struct cache_entry *ce = active_cache[i];
 		if (ce_write(&c, newfd, ce, ce_size(ce)) < 0)
 			return -1;
 	}
Index: read-tree.c
===================================================================
--- cd1c034369b73da7503da365fa556aab27004814:1/read-tree.c  (mode:100644 sha1:620f3f74eb56366fca8be4d28d7b04875c0fa90c)
+++ 77de9e0b7a81ddc22526c9415f0273171f631d3f:1/read-tree.c  (mode:100644 sha1:4ad48f5c409ead69407d2b5feab4466cdcb499f8)
@@ -261,7 +261,7 @@
 			die("just how do you expect me to merge %d trees?", stage-1);
 		}
 	}
-	if (write_cache(newfd, active_cache, active_nr) ||
+	if (write_cache(newfd) ||
 	    rename(".git/index.lock", ".git/index"))
 		die("unable to write new index file");
 	remove_lock = 0;
Index: update-cache.c
===================================================================
--- cd1c034369b73da7503da365fa556aab27004814:1/update-cache.c  (mode:100644 sha1:a09883541c745c76413c62109a80f40df4b7a7fb)
+++ 77de9e0b7a81ddc22526c9415f0273171f631d3f:1/update-cache.c  (mode:100644 sha1:585951108c57a64bb774114d289d81fd7fd22768)
@@ -341,7 +341,7 @@
 		if (add_file_to_cache(path))
 			die("Unable to add %s to database", path);
 	}
-	if (write_cache(newfd, active_cache, active_nr) ||
+	if (write_cache(newfd) ||
 	    rename(".git/index.lock", ".git/index"))
 		die("Unable to write new cachefile");
 


^ permalink raw reply

* [PATCH 00/19] summary of patch set
From: Brad Roberts @ 2005-04-21 18:34 UTC (permalink / raw)
  To: git

Tonight I did a bunch of tiny steps towards making the cache management
code behave more like a library.  There are no longer any global variables
in read-cache.c.  Nothing ever uses more than one cache yet, but I can
see how it might simplify some of the merge code.

They're also visible here:  http://gameboy2.puremagic.com:8090/

[PATCH 01/19] write_cache api signature change, isolate active_cache and active_nr inside read-cache.c
[PATCH 02/19] Add new api's to front the active_cache and active_nr cache internals
[PATCH 03/19] convert show-diff.c to use new cache hiding api's
[PATCH 04/19] Migrate update-cache.c to use the new cache api's
[PATCH 05/19] migrate checkout-cache.c to the new cache api's
[PATCH 06/19] migrate show-files.c to the new cache api's
[PATCH 07/19] migrate merge-cache.c over to the new cache api's
[PATCH 08/19] rename remove_entry_at to remove_cache_entry_at and expose as a public api
[PATCH 09/19] migrate read-tree.c to the new cache api's
[PATCH 10/19] migrate check-files.c to the new cache api's
[PATCH 11/19] migrate write-tree.c to use the new cache api's
[PATCH 12/19] fix up diff-cache.c to use new cache api's
[PATCH 13/19] Remove active_cache, active_nr, and active_alloc from public view
[PATCH 14/19] move cache_header out of the public view
[PATCH 15/19] introduce a cache struct and move the various cache globals into it.
[PATCH 16/19] change all call sites that use the return value of read_cache to get the # of cache entries.
[PATCH 17/19] temporarily change add_cache_entry to create an empty cache on demand
[PATCH 18/19] rename cache_match_stat to ce_match_stat to match other cache_entry related functions/macros
[PATCH 19/19] the end goal of the last dozen or so commits, there's no longer a global cache variable

[PATCH 01-19/19] All of the above combined

^ permalink raw reply

* Removing command dispatcher (was Re: [ANNOUNCE] git-pasky-0.6.2 && heads-up on upcoming changes)
From: David A. Wheeler @ 2005-04-21 18:15 UTC (permalink / raw)
  To: git
In-Reply-To: <pan.2005.04.21.02.48.19.802122@smurf.noris.de>

Matthias Urlichs wrote:

>Linus Torvalds wrote:
>
>  
>
>>I realize that there is probably a law that there has to be a space, but I 
>>actually personally use tab-completion all the time
>>    
>>
It's very unusual, but I can't think of any crisis it causes.

One minor annoyance: Windows doesn't support #! magic headers,
and a very few-and-probably-ignorable old Unix systems don't either.
There, commands written in an interpreter like perl, python, or shell can't
be kicked off just by a #! reference at the top (standard Windows' shell is
incompatible anyway, so it's just as well in the case of shell).

I don't see this as a roadblock, though.  On those systems, you could
create trivial stubs that just invoke the interpreter (e.g., perl) and the
real program. In the Windows case, you can use Windows' miserable
excuse for a command processor to do that very easily.
E.g., if "cg-update" is a Perl script, then you can create a file 
"cg-update.bat":
perl  \path\to\cg-update %*

(That requires Windows NT4 or better. MS-DOS didn't have %*, so you needed:
perl  \path\to\cg-update %1 %2 %3 %4 %5 %6 %7 %8 %9
It's hard to imagine an MS-DOS git user though.)

--- David A. Wheeler


^ permalink raw reply

* Re: "GIT_INDEX_FILE" environment variable
From: Davide Libenzi @ 2005-04-21 18:11 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Git Mailing List
In-Reply-To: <Pine.LNX.4.58.0504211100330.2344@ppc970.osdl.org>

On Thu, 21 Apr 2005, Linus Torvalds wrote:

> Did I already happen to mention that I think that the git model is the
> best model ever, and that I'm just not an incredibly good-looking hunk and
> becomingly modest, I'm smart too?

You forgot, *again*, to take your medications !!



- Davide


^ permalink raw reply

* "GIT_INDEX_FILE" environment variable
From: Linus Torvalds @ 2005-04-21 18:09 UTC (permalink / raw)
  To: Git Mailing List


This checkin goes along with the previous one, and makes it easier to use 
all the normal git operations on temporary index files:

  Add support for a "GIT_INDEX_FILE" environment variable.
  
  We use that to specify alternative index files, which can be useful
  if you want to (for example) generate a temporary index file to do
  some specific operation that you don't want to mess with your main
  one with.
  
  It defaults to the regular ".git/index" if it hasn't been specified.

and it's particularly useful for doing things like "read a tree into a 
temporary index file, and write the result out". For example, say that you 
wanted to know what the Makefile looked like in a particular release, 
you could do

    GIT_INDEX_FILE=.tmp-index read-tree $release
    GIT_INDEX_FILE=.tmp-index checkout-cache --prefix=old- Makefile
    rm .tmp-index

and you're done. Your old Makefile version is now in "old-Makefile" (and
this is also where it's nice that checkout-cache refuses to overwrite
existing files by default: if you forgot or messed up the prefix, it's all
good).

You can also use it to test merges without screwing up your old index file 
in case something goes wrong.

Did I already happen to mention that I think that the git model is the
best model ever, and that I'm just not an incredibly good-looking hunk and
becomingly modest, I'm smart too?

		Linus

^ permalink raw reply

* "checkout-cache" update
From: Linus Torvalds @ 2005-04-21 17:40 UTC (permalink / raw)
  To: Git Mailing List


I just pushed out this very useful thing to "checkout-cache", which is 
best just described by its commit log:

  Add the ability to prefix something to the pathname to "checkout-cache.c"
  
  This basically makes it trivial to use checkout-cache as a "export as
  tree" function. Just read the desired tree into the index, and do a
  
        checkout-cache --prefix=export-dir/ -a
  
  and checkout-cache will "export" the cache into the specified directory.
  
  NOTE! The final "/" is important. The exported name is literally just
  prefixed with the specified string, so you can also do something like
  
        checkout-cache --prefix=.merged- Makefile
  
  to check out the currently cached copy of "Makefile" into the file
  ".merged-Makefile".

Basically, I can do a a "git-0.6" release with a simple

	checkout-cache --prefix=../git-0.6/ -a

which basically says: check out all files, but use the prefix 
"../git-0.6/" before the filename when you do so.

Then I just do

	cd ..
	tar czvf git-0.6.tar.gz git-0.6

and I'm done. Very cool, very simple, and _extremely_ fast.

Doing the tree export (not the tar) for the whole kernel takes two minutes
in the cold-cache case (not so wonderful, but acceptable), and 4.6
_seconds_ in the hot-cache case (pretty damn impressive, I say).

(The compressng tar then takes about 20 seconds for me, and that's
obviously all from the cache, since I just wrote it out).

NOTE! The fact that the '/' at the end of the --prefix= thing is 
meaningful can be very confusing, I freely admit. But it does end up being 
potentially quite useful, and you're likely to script usage of this anyway 
into "git export" or something, so...

		Linus

^ permalink raw reply

* Re: zlib version, list archives
From: Randy.Dunlap @ 2005-04-21 17:25 UTC (permalink / raw)
  To: jschopp; +Cc: git
In-Reply-To: <4267E0A4.40506@austin.ibm.com>

On Thu, 21 Apr 2005 12:19:32 -0500 Joel Schopp wrote:

| I downloaded git-pasky 0.6.2.  I cannot compile it because my zlib 
| version is 1.1.4 and git-pasky relies on function deflateBound() which 
| wasn't introduced until zlib version 1.2.x  Is there a patch out there 
| to work around this and maybe conditionally compile based on the zlib 
| version?
| 
| I apologize in advance if this has already been asked, I cannot find an 
| archive of this list.  Could somebody point me to one?

http://marc.theaimsgroup.com/?l=git
or
http://dir.gmane.org/gmane.comp.version-control.git

---
~Randy

^ permalink raw reply

* zlib version, list archives
From: Joel Schopp @ 2005-04-21 17:19 UTC (permalink / raw)
  To: git

I downloaded git-pasky 0.6.2.  I cannot compile it because my zlib 
version is 1.1.4 and git-pasky relies on function deflateBound() which 
wasn't introduced until zlib version 1.2.x  Is there a patch out there 
to work around this and maybe conditionally compile based on the zlib 
version?

I apologize in advance if this has already been asked, I cannot find an 
archive of this list.  Could somebody point me to one?


^ permalink raw reply

* RE: on when to checksum
From: Andrew Timberlake-Newell @ 2005-04-21 16:53 UTC (permalink / raw)
  To: 'Tom Lord'; +Cc: torvalds, git
In-Reply-To: <200504202225.PAA15992@emf.net>

Tom Lord graced us with:
> I think you have made a mistake by moving the sha1 checksum from the
> zipped form to the inflated form.  Here is why:
> 
> What you have set in motion with `git' is an ad-hoc p2p network for
> sharing filesystem trees -- a global distributed filesystem.  I
> believe your starter here has a good chance of taking off to be much,
> much larger than just a tool for the kernel.

This might rather be a call for a git derivative.

As Linus has already mentioned in this thread, git is optimized for his need
for local speed.  But while sacrificing local speed for network speed would
break git by stepping away from the git philosophy, a gitling with a
different philosophy but making use of gitish techniques could make that
change without being broken even though git itself can't.



^ permalink raw reply

* Re: git-viz tool for visualising commit trees
From: Petr Baudis @ 2005-04-21 16:45 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Olivier Andrieu, git
In-Reply-To: <20050421144716.GA15136@elte.hu>

Dear diary, on Thu, Apr 21, 2005 at 04:47:16PM CEST, I got a letter
where Ingo Molnar <mingo@elte.hu> told me that...
> 
> is the 'diff with ancestor' feature supposed to work at this early 
> stage? (it just does nothing when i click on it. It correctly offers two 
> ancestors for merge points, but does nothing there either.)

Doesn't it require git diff?

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply

* Re: [PATCH] Improve usage messages
From: David Greaves @ 2005-04-21 16:43 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Matthias Urlichs, git
In-Reply-To: <20050421162505.GE30991@pasky.ji.cz>

Petr Baudis wrote:
> Dear diary, on Thu, Apr 21, 2005 at 02:41:52PM CEST, I got a letter
> where Matthias Urlichs <smurf@smurf.noris.de> told me that...
> 
>>This patch adds somewhat-improved usage messages to some of Linus' programs.
>>Specifically, they now handle -? / --help.

just so you know, the intention of doing the README.reference was to get 
all the docs in one place and then go back to the c and update the 
usage() to be consistent.

I started by doing
   grep usage *.c
:)

I'm actually working on diff-cache as we speak...

David

^ permalink raw reply

* Re: [ANNOUNCE] git-pasky-0.6.2 && heads-up on upcoming changes
From: Petr Baudis @ 2005-04-21 16:42 UTC (permalink / raw)
  To: Edgar Toernig; +Cc: git
In-Reply-To: <20050421162100.068146b9.froese@gmx.de>

Dear diary, on Thu, Apr 21, 2005 at 04:21:00PM CEST, I got a letter
where Edgar Toernig <froese@gmx.de> told me that...
> Petr Baudis wrote:
> >
> > A little off-topic, anyone knows how to turn off that damn alternate
> > screen thing on the xterm level? (Or any other level which makes _all_
> > programs not to use it.)
> 
> Change the terminfo entry.

That's why I asked for how to do it on the xterm level. Some programs
don't care about term(cap|info). And I may not be root.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply

* Re: Switching between branches
From: Petr Baudis @ 2005-04-21 16:39 UTC (permalink / raw)
  To: Matthias Urlichs; +Cc: git
In-Reply-To: <pan.2005.04.21.14.12.46.905838@smurf.noris.de>

Dear diary, on Thu, Apr 21, 2005 at 04:12:49PM CEST, I got a letter
where Matthias Urlichs <smurf@smurf.noris.de> told me that...
> Hi, Petr Baudis wrote:
> 
> > Hello,
> > 
> >> Perhaps it's a naive question, but how do I switch between branches?  I
> >> mean an equivalent of "svn switch" or "cvs update -r branch" that would
> >> reuse the existing working directory.
> > 
> > you can't. There was 'git update' (and intermediate never-committed 'git
> > switch'), but I decided not to support it for now, since I don't have any
> > compelling usage case for it.
> 
> I do -- I have a project which builds several slightly-customized versions,
> and I'd like to keep the generated objects around if possible.
> 
> So I just build one version, then "git cancel FOO" to the next version,
> and let the make rules take care of rebuilding what needs to be rebuilt.

I suppose we could do with git switch then.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply

* Re: [PATCH] Missing linefeeds
From: Petr Baudis @ 2005-04-21 16:26 UTC (permalink / raw)
  To: Matthias Urlichs; +Cc: git
In-Reply-To: <20050421124430.ACDC77F894@smurf.noris.de>

Dear diary, on Thu, Apr 21, 2005 at 02:44:30PM CEST, I got a letter
where Matthias Urlichs <smurf@smurf.noris.de> told me that...
> This patch fixes die() and error() to print linefeeds after the message.

Why? report() already prints linefeed.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ 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