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

Re: [PATCH 1/2] restore legacy behavior for read_sha1_file()

From
Nicolas Pitre <nico@cam.org>
Date
Jul 15, 2008, 05:12 UTC
Message-ID
<alpine.LFD.1.10.0807150111110.12484@xanadu.home>
In-Reply-To
<alpine.LFD.1.10.0807142134450.12484@xanadu.home>
On Mon, 14 Jul 2008, Nicolas Pitre wrote:
Show 11 quoted lines
> Since commit 8eca0b47ff1598a6d163df9358c0e0c9bd92d4c8, it is possible
> for read_sha1_file() to return NULL even with existing objects when they
> are corrupted.  Previously a corrupted object would have terminated the
> program immediately, effectively making read_sha1_file() return NULL 
> only when specified object is not found.
> 
> Let's restore this behavior for all users of read_sha1_file() and 
> provide a separate function with the ability to not terminate when
> bad objects are encountered.
> 
> Signed-off-by: Nicolas Pitre <nico@cam.org>

Grrrr. Forgot to 'git add' one file. So this goes with the same commit:

diff --git a/cache.h b/cache.h
index 4a8b125..bc52af6 100644
--- a/cache.h
+++ b/cache.h
@@ -540,6 +540,9 @@ extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsig
 extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
 extern int force_object_loose(const unsigned char *sha1, time_t mtime);
 
+/* just like read_sha1_file(), but non fatal in presence of bad objects */
+extern void *read_object(const unsigned char *sha1, enum object_type *type, unsigned long *size);
+
 extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
 
 extern int move_temp_to_file(const char *tmpfile, const char *filename);
Previous: Nicolas PitreNext: Shawn O. Pearce
Message 8 of 9 in “[BUG] commit walk machinery is dangerous !”
  1. Nicolas PitreJul 14, 2008
  2. Junio C HamanoJul 14, 2008
  3. Nicolas PitreJul 14, 2008
  4. Junio C HamanoJul 14, 2008
  5. Nicolas PitreJul 14, 2008
  6. 1/2 restore legacy behavior for read_sha1_file()Nicolas Pitre, Jul 15, 2008
  7. 2/2 test case for previous commitNicolas Pitre, Jul 15, 2008
  8. Nicolas PitreJul 15, 2008
  9. unpack_entry (was: [BUG] commit walk machinery is dangerous !)Shawn O. Pearce, Jul 15, 2008

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.