login
Header Space

 
 

[PATCH] make sha1_file.c::matches_pack_name() available to others

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Nicolas Pitre <nico@...>
Cc: Linus Torvalds <torvalds@...>, Johannes Schindelin <Johannes.Schindelin@...>, Nix <nix@...>, Steven Grimm <koreth@...>, Git Mailing List <git@...>
Date: Saturday, September 8, 2007 - 5:50 am

Even though our convention is "zero return means good", it goes a
bit too far for matches_pack_name() to return 0 when it found
the pack is what the name refers to.  This fixes that silly and
obvious interface bug.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 Junio C Hamano <gitster@pobox.com> writes:

 > Nicolas Pitre <nico@cam.org> writes:
 > ...
 >> In fact, since we want to _also_ perform a repack of loose objects in 
 >> the context of automatic repacking, I wonder why we wouldn't use that 
 >> --unpacked= argument to also repack smallish packs at the same time in 
 >> only one pack-objects pass.  Or maybe I'm missing something?
 >
 > I think this is a much better idea.  You obviously need some
 > twist to the pack-objects, and being lazy that was the reason I
 > did not want to do this that way.

 So what follows is two-patch series, which still is a rough
 sketch, as I am feeling a bit too tired to do tests and
 documentation (help is always welcomed, hint hint).

 This message contains the first one, which is more or less
 independent, that exposes matches_pack_name() function from
 sha1_file.c, while fixing a silly and obvious interface bug.

 cache.h     |    1 +
 sha1_file.c |   14 +++++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/cache.h b/cache.h
index 70abbd5..3fa5b8e 100644
--- a/cache.h
+++ b/cache.h
@@ -529,6 +529,7 @@ extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsign
 extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
 extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
 extern const char *packed_object_info_detail(struct packed_git *, off_t, unsigned long *, unsigned long *, unsigned int *, unsigned char *);
+extern int matches_pack_name(struct packed_git *p, const char *name);
 
 /* Dumb servers support */
 extern int update_server_info(int);
diff --git a/sha1_file.c b/sha1_file.c
index 9978a58..5801c3e 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1684,22 +1684,22 @@ off_t find_pack_entry_one(const unsigned char *sha1,
 	return 0;
 }
 
-static int matches_pack_name(struct packed_git *p, const char *ig)
+int matches_pack_name(struct packed_git *p, const char *name)
 {
 	const char *last_c, *c;
 
-	if (!strcmp(p->pack_name, ig))
-		return 0;
+	if (!strcmp(p->pack_name, name))
+		return 1;
 
 	for (c = p->pack_name, last_c = c; *c;)
 		if (*c == '/')
 			last_c = ++c;
 		else
 			++c;
-	if (!strcmp(last_c, ig))
-		return 0;
+	if (!strcmp(last_c, name))
+		return 1;
 
-	return 1;
+	return 0;
 }
 
 static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed)
@@ -1717,7 +1717,7 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
 		if (ignore_packed) {
 			const char **ig;
 			for (ig = ignore_packed; *ig; ig++)
-				if (!matches_pack_name(p, *ig))
+				if (matches_pack_name(p, *ig))
 					break;
 			if (*ig)
 				goto next;


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
People unaware of the importance of "git gc"?, Linus Torvalds, (Wed Sep 5, 3:09 am)
Re: People unaware of the importance of "git gc"?, Alex Riesen, (Wed Sep 5, 5:07 pm)
Re: People unaware of the importance of "git gc"?, J. Bruce Fields, (Wed Sep 5, 1:44 pm)
Re: People unaware of the importance of "git gc"?, Brandon Casey, (Wed Sep 5, 2:46 pm)
Re: People unaware of the importance of "git gc"?, David Kastrup, (Wed Sep 5, 3:09 pm)
Re: People unaware of the importance of "git gc"?, Mike Hommey, (Wed Sep 5, 3:20 pm)
Re: People unaware of the importance of "git gc"?, J. Bruce Fields, (Wed Sep 5, 3:13 pm)
Re: People unaware of the importance of "git gc"?, David Kastrup, (Wed Sep 5, 3:43 pm)
Re: People unaware of the importance of "git gc"?, Govind Salinas, (Wed Sep 5, 12:47 pm)
Re: People unaware of the importance of "git gc"?, Steven Grimm, (Wed Sep 5, 1:35 pm)
Re: People unaware of the importance of "git gc"?, Carl Worth, (Wed Sep 5, 1:19 pm)
Re: People unaware of the importance of "git gc"?, David Kastrup, (Wed Sep 5, 4:16 am)
Re: People unaware of the importance of "git gc"?, Pierre Habouzit, (Wed Sep 5, 3:42 am)
Re: People unaware of the importance of "git gc"?, Steven Grimm, (Wed Sep 5, 2:14 pm)
Re: People unaware of the importance of "git gc"?, Nicolas Pitre, (Wed Sep 5, 2:54 pm)
Re: People unaware of the importance of "git gc"?, Junio C Hamano, (Wed Sep 5, 4:01 pm)
Re: People unaware of the importance of "git gc"?, Johannes Schindelin, (Thu Sep 6, 11:54 am)
Re: People unaware of the importance of "git gc"?, Junio C Hamano, (Thu Sep 6, 1:49 pm)
Re: People unaware of the importance of "git gc"?, Johannes Schindelin, (Fri Sep 7, 6:12 am)
Re: People unaware of the importance of "git gc"?, Shawn O. Pearce, (Fri Sep 7, 12:48 am)
Re: People unaware of the importance of "git gc"?, Linus Torvalds, (Thu Sep 6, 2:15 pm)
Subject: [PATCH] git-merge-pack, Junio C Hamano, (Thu Sep 6, 7:12 pm)
Re: Subject: [PATCH] git-merge-pack, Andy Parkins, (Fri Sep 7, 3:24 am)
Re: Subject: [PATCH] git-merge-pack, Johannes Sixt, (Fri Sep 7, 3:11 am)
Re: Subject: [PATCH] git-merge-pack, Junio C Hamano, (Fri Sep 7, 3:34 am)
Re: Subject: [PATCH] git-merge-pack, Nicolas Pitre, (Thu Sep 6, 8:51 pm)
Re: Subject: [PATCH] git-merge-pack, Junio C Hamano, (Fri Sep 7, 12:43 am)
[PATCH] pack-objects --repack-unpacked, Junio C Hamano, (Sat Sep 8, 6:01 am)
Re: [PATCH] pack-objects --repack-unpacked, Shawn O. Pearce, (Sat Sep 8, 10:57 pm)
Re: [PATCH] pack-objects --repack-unpacked, Junio C Hamano, (Sun Sep 9, 1:04 am)
Re: [PATCH] pack-objects --repack-unpacked, Nicolas Pitre, (Sun Sep 9, 8:29 am)
Re: [PATCH] pack-objects --repack-unpacked, Shawn O. Pearce, (Sun Sep 9, 1:49 pm)
[PATCH] make sha1_file.c::matches_pack_name() available to o..., Junio C Hamano, (Sat Sep 8, 5:50 am)
Re: Subject: [PATCH] git-merge-pack, Shawn O. Pearce, (Fri Sep 7, 12:07 am)
Re: Subject: [PATCH] git-merge-pack, Junio C Hamano, (Thu Sep 6, 9:58 pm)
Re: Subject: [PATCH] git-merge-pack, Nicolas Pitre, (Thu Sep 6, 10:32 pm)
Re: Subject: [PATCH] git-merge-pack, Linus Torvalds, (Thu Sep 6, 7:35 pm)
Re: People unaware of the importance of "git gc"?, Steven Grimm, (Thu Sep 6, 2:29 pm)
Re: People unaware of the importance of "git gc"?, Shawn O. Pearce, (Wed Sep 5, 10:45 pm)
Re: People unaware of the importance of "git gc"?, Steven Grimm, (Wed Sep 5, 10:49 pm)
Re: People unaware of the importance of "git gc"?, Shawn O. Pearce, (Wed Sep 5, 10:56 pm)
Re: People unaware of the importance of "git gc"?, Alex Riesen, (Wed Sep 5, 5:18 pm)
Re: [PATCH] Invoke "git gc --auto" from "git add" and "git f..., Johannes Schindelin, (Thu Sep 6, 8:02 am)
Re: People unaware of the importance of "git gc"?, Nicolas Pitre, (Wed Sep 5, 4:35 pm)
Re: People unaware of the importance of "git gc"?, Junio C Hamano, (Wed Sep 5, 5:49 pm)
Invoke "git gc --auto" from commit, merge, am and rebase., Junio C Hamano, (Wed Sep 5, 5:59 pm)
Re: People unaware of the importance of "git gc"?, Junio C Hamano, (Wed Sep 5, 5:46 pm)
Re: People unaware of the importance of "git gc"?, David Kastrup, (Thu Sep 6, 1:55 am)
Re: People unaware of the importance of "git gc"?, Nicolas Pitre, (Wed Sep 5, 7:04 pm)
Re: People unaware of the importance of "git gc"?, Junio C Hamano, (Wed Sep 5, 7:42 pm)
Re: People unaware of the importance of "git gc"?, Carlos Rica, (Wed Sep 5, 8:27 pm)
Re: People unaware of the importance of "git gc"?, Steven Grimm, (Wed Sep 5, 4:50 am)
Re: People unaware of the importance of "git gc"?, David Kastrup, (Wed Sep 5, 5:13 am)
Re: People unaware of the importance of "git gc"?, Pierre Habouzit, (Wed Sep 5, 5:14 am)
Re: People unaware of the importance of "git gc"?, Junio C Hamano, (Wed Sep 5, 5:07 am)
Re: People unaware of the importance of "git gc"?, Martin Langhoff, (Wed Sep 5, 5:27 am)
Re: People unaware of the importance of "git gc"?, Matthieu Moy, (Wed Sep 5, 5:33 am)
Re: People unaware of the importance of "git gc"?, Johan De Messemaeker, (Wed Sep 5, 10:17 am)
Re: People unaware of the importance of "git gc"?, Matthieu Moy, (Wed Sep 5, 1:31 pm)
Re: People unaware of the importance of "git gc"?, Jeff King, (Wed Sep 5, 7:56 pm)
Re: People unaware of the importance of "git gc"?, Junio C Hamano, (Wed Sep 5, 4:16 am)
Re: People unaware of the importance of "git gc"?, Junio C Hamano, (Wed Sep 5, 3:30 am)
Re: People unaware of the importance of "git gc"?, Wincent Colaiuta, (Wed Sep 5, 4:51 am)
Re: People unaware of the importance of "git gc"?, Johan Herland, (Wed Sep 5, 4:13 am)
Re: People unaware of the importance of "git gc"?, Matthieu Moy, (Wed Sep 5, 4:39 am)
Re: People unaware of the importance of "git gc"?, Pierre Habouzit, (Wed Sep 5, 4:51 am)
Re: People unaware of the importance of "git gc"?, Matthieu Moy, (Wed Sep 5, 5:04 am)
Re: People unaware of the importance of "git gc"?, Johan Herland, (Wed Sep 5, 4:41 am)
Re: People unaware of the importance of "git gc"?, Tomash Brechko, (Wed Sep 5, 3:26 am)
Re: People unaware of the importance of "git gc"?, Martin Langhoff, (Wed Sep 5, 3:21 am)
speck-geostationary