From: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH 2/5] git-tar-tree: add TYPEFLAG_ constants
Date: Fri, 6 May 2005 22:55:52 +0200 [thread overview]
Message-ID: <20050506205552.GC19518@lsrfire.ath.cx> (raw)
Add TYPEFLAG_ constants.
---
commit c0507f354f3637ce2fc6d8665685a7007e97002e
tree c20d5f820ce6cd1763af5a3eccfe4d4cff1ac719
parent 487c69a1df2a28471e1cefc1ae592cb61a57530e
author Rene Scharfe <rene.scharfe@lsrfire.ath.cx> 1115304862 +0200
committer Rene Scharfe <rene.scharfe@lsrfire.ath.cx> 1115304862 +0200
Index: tar-tree.c
===================================================================
--- 2179101bba7891ba96b070265068edeb9233d435/tar-tree.c (mode:100644 sha1:06f4ca480e0d212b51970debdbf97a3379225330)
+++ c20d5f820ce6cd1763af5a3eccfe4d4cff1ac719/tar-tree.c (mode:100644 sha1:a5b9fc937c6c54a8155dd8d28772ecb5ba5dd303)
@@ -4,6 +4,12 @@
#define RECORDSIZE (512)
#define BLOCKSIZE (RECORDSIZE * 20)
+#define TYPEFLAG_AUTO '\0'
+#define TYPEFLAG_REG '0'
+#define TYPEFLAG_DIR '5'
+#define TYPEFLAG_GLOBAL_HEADER 'g'
+#define TYPEFLAG_EXT_HEADER 'x'
+
static const char *tar_tree_usage = "tar-tree <key> [basedir]";
static char block[BLOCKSIZE];
@@ -186,7 +192,8 @@
size++;
if (size > RECORDSIZE)
die("tar-tree: extended header too big, wtf?");
- write_header(NULL, 'x', NULL, NULL, headerfilename, 0100600, size);
+ write_header(NULL, TYPEFLAG_EXT_HEADER, NULL, NULL, headerfilename,
+ 0100600, size);
p = get_record();
append_long(&p, size);
append_string(&p, " path=");
@@ -198,7 +205,8 @@
static void write_global_extended_header(const char *sha1)
{
char *p;
- write_header(NULL, 'g', NULL, NULL, "pax_global_header", 0, 52);
+ write_header(NULL, TYPEFLAG_GLOBAL_HEADER, NULL, NULL,
+ "pax_global_header", 0100600, 52);
p = get_record();
append_long(&p, 52); /* 2 + 9 + 40 + 1 */
append_string(&p, " comment=");
@@ -217,6 +225,13 @@
unsigned int checksum = 0;
int i;
+ if (typeflag == TYPEFLAG_AUTO) {
+ if (S_ISDIR(mode))
+ typeflag = TYPEFLAG_DIR;
+ else
+ typeflag = TYPEFLAG_REG;
+ }
+
namelen = path_len(S_ISDIR(mode), basepath, prefix, path);
if (namelen > 500) {
die("tar-tree: name too log of object %s\n", sha1_to_hex(sha1));
@@ -287,8 +302,8 @@
eltbuf = read_sha1_file(sha1, elttype, &eltsize);
if (!eltbuf)
die("cannot read %s", sha1_to_hex(sha1));
- write_header(sha1, S_ISDIR(mode) ? '5' : '0', basedir,
- prefix, path, mode, eltsize);
+ write_header(sha1, TYPEFLAG_AUTO, basedir, prefix, path,
+ mode, eltsize);
if (!strcmp(elttype, "tree")) {
this_prefix.name = path;
traverse_tree(eltbuf, eltsize, &this_prefix);
@@ -362,7 +377,7 @@
if (!archive_time)
archive_time = time(NULL);
if (basedir)
- write_header("0", '5', NULL, NULL, basedir, 040755, 0);
+ write_header("0", TYPEFLAG_DIR, NULL, NULL, basedir, 040755, 0);
traverse_tree(buffer, size, NULL);
free(buffer);
write_trailer();
\f
!-------------------------------------------------------------flip-
reply other threads:[~2005-05-06 20:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050506205552.GC19518@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox