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

[PATCH 1/5] git-tar-tree: add get_record()

From
Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
May 6, 2005, 20:55 UTC
Message-ID
<20050506205542.GB19518@lsrfire.ath.cx>
Add get_record() which returns a pointer to the next record in the block.

--- commit 487c69a1df2a28471e1cefc1ae592cb61a57530e tree 2179101bba7891ba96b070265068edeb9233d435 parent e0965d83c533e8b6a51f1c6c1be12f5edee5ca65 author Rene Scharfe <rene.scharfe@lsrfire.ath.cx> 1115304529 +0200 committer Rene Scharfe <rene.scharfe@lsrfire.ath.cx> 1115304529 +0200

Index: tar-tree.c
===================================================================
--- c5ee2c11b8d4214dd6fde6388a12060e5d86b06c/tar-tree.c  (mode:100644 sha1:2c64f690e52093af13585521de4df478ac6e85e5)
+++ 2179101bba7891ba96b070265068edeb9233d435/tar-tree.c  (mode:100644 sha1:06f4ca480e0d212b51970debdbf97a3379225330)
@@ -45,6 +45,15 @@
 	}
 }
 
+/* acquire the next record from the buffer; user must call write_if_needed() */
+static char *get_record(void)
+{
+	char *p = block + offset;
+	memset(p, 0, RECORDSIZE);
+	offset += RECORDSIZE;
+	return p;
+}
+
 /*
  * The end of tar archives is marked by 1024 nul bytes and after that
  * follows the rest of the block (if any).
@@ -178,9 +187,7 @@
 	if (size > RECORDSIZE)
 		die("tar-tree: extended header too big, wtf?");
 	write_header(NULL, 'x', NULL, NULL, headerfilename, 0100600, size);
-	p = block + offset;
-	memset(p, 0, RECORDSIZE);
-	offset += RECORDSIZE;
+	p = get_record();
 	append_long(&p, size);
 	append_string(&p, " path=");
 	append_path(&p, is_dir, basepath, prefix, path);
@@ -192,9 +199,7 @@
 {
 	char *p;
 	write_header(NULL, 'g', NULL, NULL, "pax_global_header", 0, 52);
-	p = block + offset;
-	memset(p, 0, RECORDSIZE);
-	offset += RECORDSIZE;
+	p = get_record();
 	append_long(&p, 52);	/* 2 + 9 + 40 + 1 */
 	append_string(&p, " comment=");
 	append_string(&p, sha1_to_hex(sha1));
@@ -223,15 +228,10 @@
 		write_extended_header(headerfilename, S_ISDIR(mode), basepath,
 				      prefix, path, namelen);
 
-		header = block + offset;
-		memset(header, 0, RECORDSIZE);
-		offset += RECORDSIZE;
+		header = get_record();
 		sprintf(header, "%s.data", sha1_hex);
 	} else {
-		header = block + offset;
-		memset(header, 0, RECORDSIZE);
-		offset += RECORDSIZE;
-		p = header;
+		p = header = get_record();
 		append_path(&p, S_ISDIR(mode), basepath, prefix, path);
 	}
 



!-------------------------------------------------------------flip-
Message 1 of 1 in “git-tar-tree: add get_record()”
  1. 1/5 git-tar-tree: add get_record()Rene Scharfe, May 6, 2005

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.