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

Re: [PATCH v2] Make sure objects/pack exists before creating a new pack

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Feb 26, 2009, 09:19 UTC
Message-ID
<49A65EBF.10307@viscovery.net>
In-Reply-To
<7vocwrc7oe.fsf_-_@gitster.siamese.dyndns.org>
Junio C Hamano schrieb:
Show 8 quoted lines
> @@ -795,22 +794,24 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
>  
>  	if (keep_msg) {
>  		int keep_fd, keep_msg_len = strlen(keep_msg);
> -		if (!keep_name) {
> -			snprintf(name, sizeof(name), "%s/pack/pack-%s.keep",
> -				 get_object_directory(), sha1_to_hex(sha1));
> -			keep_name = name;
You should not have removed this line...
Show 13 quoted lines
> -		}
> -		keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
> +
> +		if (!keep_name)
> +			keep_fd = odb_pack_keep(name, sizeof(name), sha1);
> +		else
> +			keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);
> +
>  		if (keep_fd < 0) {
>  			if (errno != EEXIST)
> -				die("cannot write keep file");
> +				die("cannot write keep file '%s' (%s)",
> +				    keep_name, strerror(errno));
... we need keep_name for this error message.
Warning: I did not test the failure path; but I made sure that these
tests pass on Windows:
cd t && make *fetch* *pack* *index* *pull*
-- snip --
From: Johannes Sixt <j6t@kdbg.org>
Subject: [PATCH] index-pack: Set keep_name if a new keep file was allocated

6e180cdc (Make sure objects/pack exists before creating a new pack, 2009-02-25) simplified the code in this area, but it also extended an error message to include the file name that caused the error. However, one code path did not set file name correctly.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 index-pack.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/index-pack.c b/index-pack.c
index 7fee872..93a09c6 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -794,9 +794,10 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
 	if (keep_msg) {
 		int keep_fd, keep_msg_len = strlen(keep_msg);

-		if (!keep_name)
+		if (!keep_name) {
 			keep_fd = odb_pack_keep(name, sizeof(name), sha1);
-		else
+			keep_name = name;
+		} else
 			keep_fd = open(keep_name, O_RDWR|O_CREAT|O_EXCL, 0600);

 		if (keep_fd < 0) {
-- 
1.6.2.rc2.1005.gb0117
Previous: Junio C HamanoNext: Mike Ralphson
Message 6 of 10 in “git-push error: Cannot write keep file”
  1. Rafael Darder CalvoFeb 24, 2009
  2. Junio C HamanoFeb 24, 2009
  3. Rafael Darder CalvoFeb 24, 2009
  4. Make sure objects/pack exists before creating a new packJunio C Hamano, Feb 25, 2009
  5. Junio C HamanoFeb 25, 2009
  6. Johannes SixtFeb 26, 2009
  7. Mike RalphsonFeb 26, 2009
  8. Johannes SixtFeb 26, 2009
  9. Mike RalphsonFeb 26, 2009
  10. Junio C HamanoFeb 26, 2009

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.