git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/8] Export matches_pack_name() and fix its return value

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 17, 2007, 08:44 UTC
Message-ID
<11900186941912-git-send-email-gitster@pobox.com>

The function sounds boolean; make it behave as one, not "0 for success, non-zero for failure".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 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;
-- 
1.5.3.1.967.g6bb01
Next: Junio C Hamano
Message 1 of 18 in “Export matches_pack_name() and fix its return value”
  1. 1/8 Export matches_pack_name() and fix its return valueJunio C Hamano, Sep 17, 2007
  2. 2/8 pack-objects --keep-unreachableJunio C Hamano, Sep 17, 2007
  3. 3/8 repack -A -d: use --keep-unreachable when repackingJunio C Hamano, Sep 17, 2007
  4. Johannes SchindelinSep 17, 2007
  5. Andreas EricssonSep 17, 2007
  6. Shawn O. PearceSep 18, 2007
  7. 4/8 git-gc --auto: move threshold check to need_to_gc() function.Junio C Hamano, Sep 17, 2007
  8. 5/8 git-gc --auto: add documentation.Junio C Hamano, Sep 17, 2007
  9. Johannes SchindelinSep 17, 2007
  10. Junio C HamanoSep 17, 2007
  11. 6/8 git-gc --auto: protect ourselves from accumulated cruftJunio C Hamano, Sep 17, 2007
  12. 7/8 git-gc --auto: restructure the way "repack" command line is built.Junio C Hamano, Sep 17, 2007
  13. Johannes SchindelinSep 17, 2007
  14. Junio C HamanoSep 17, 2007
  15. 8/8 git-gc --auto: run "repack -A -d -l" as necessary.Junio C Hamano, Sep 17, 2007
  16. Johannes SchindelinSep 17, 2007
  17. Junio C HamanoSep 17, 2007
  18. Shawn O. PearceSep 18, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.