{"thread":{"id":"510","subject":"[PATCH 1/5] git-tar-tree: add get_record()","startedAt":"2005-05-06T20:55:42Z","lastAt":"2005-05-06T20:55:42Z","messageCount":1,"participants":["Rene Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"2703","messageId":"20050506205542.GB19518@lsrfire.ath.cx","threadId":"510","inReplyTo":null,"subject":"[PATCH 1/5] git-tar-tree: add get_record()","fromName":"Rene Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2005-05-06T20:55:42Z","receivedAt":"2005-05-06T20:55:42Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Add get_record() which returns a pointer to the next record in the block.\n\n---\ncommit 487c69a1df2a28471e1cefc1ae592cb61a57530e\ntree 2179101bba7891ba96b070265068edeb9233d435\nparent e0965d83c533e8b6a51f1c6c1be12f5edee5ca65\nauthor Rene Scharfe <rene.scharfe@lsrfire.ath.cx> 1115304529 +0200\ncommitter Rene Scharfe <rene.scharfe@lsrfire.ath.cx> 1115304529 +0200\n\nIndex: tar-tree.c\n===================================================================\n--- c5ee2c11b8d4214dd6fde6388a12060e5d86b06c/tar-tree.c  (mode:100644 sha1:2c64f690e52093af13585521de4df478ac6e85e5)\n+++ 2179101bba7891ba96b070265068edeb9233d435/tar-tree.c  (mode:100644 sha1:06f4ca480e0d212b51970debdbf97a3379225330)\n@@ -45,6 +45,15 @@\n \t}\n }\n \n+/* acquire the next record from the buffer; user must call write_if_needed() */\n+static char *get_record(void)\n+{\n+\tchar *p = block + offset;\n+\tmemset(p, 0, RECORDSIZE);\n+\toffset += RECORDSIZE;\n+\treturn p;\n+}\n+\n /*\n  * The end of tar archives is marked by 1024 nul bytes and after that\n  * follows the rest of the block (if any).\n@@ -178,9 +187,7 @@\n \tif (size > RECORDSIZE)\n \t\tdie(\"tar-tree: extended header too big, wtf?\");\n \twrite_header(NULL, 'x', NULL, NULL, headerfilename, 0100600, size);\n-\tp = block + offset;\n-\tmemset(p, 0, RECORDSIZE);\n-\toffset += RECORDSIZE;\n+\tp = get_record();\n \tappend_long(&p, size);\n \tappend_string(&p, \" path=\");\n \tappend_path(&p, is_dir, basepath, prefix, path);\n@@ -192,9 +199,7 @@\n {\n \tchar *p;\n \twrite_header(NULL, 'g', NULL, NULL, \"pax_global_header\", 0, 52);\n-\tp = block + offset;\n-\tmemset(p, 0, RECORDSIZE);\n-\toffset += RECORDSIZE;\n+\tp = get_record();\n \tappend_long(&p, 52);\t/* 2 + 9 + 40 + 1 */\n \tappend_string(&p, \" comment=\");\n \tappend_string(&p, sha1_to_hex(sha1));\n@@ -223,15 +228,10 @@\n \t\twrite_extended_header(headerfilename, S_ISDIR(mode), basepath,\n \t\t\t\t      prefix, path, namelen);\n \n-\t\theader = block + offset;\n-\t\tmemset(header, 0, RECORDSIZE);\n-\t\toffset += RECORDSIZE;\n+\t\theader = get_record();\n \t\tsprintf(header, \"%s.data\", sha1_hex);\n \t} else {\n-\t\theader = block + offset;\n-\t\tmemset(header, 0, RECORDSIZE);\n-\t\toffset += RECORDSIZE;\n-\t\tp = header;\n+\t\tp = header = get_record();\n \t\tappend_path(&p, S_ISDIR(mode), basepath, prefix, path);\n \t}\n \n\n\n\f\n!-------------------------------------------------------------flip-\n\n\n"}]}