{"thread":{"id":"1165","subject":"[PATCH] add --no-check option to git-write-tree","startedAt":"2005-07-08T10:37:48Z","lastAt":"2005-07-08T19:42:00Z","messageCount":2,"participants":["Bryan Larsen","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"5815","messageId":"42CE577C.1070404@gmail.com","threadId":"1165","inReplyTo":null,"subject":"[PATCH] add --no-check option to git-write-tree","fromName":"Bryan Larsen","fromEmail":"bryan.larsen@gmail.com","sentAt":"2005-07-08T10:37:48Z","receivedAt":"2005-07-08T10:37:48Z","isPatch":true,"sender":{"key":"bryan@larsen.st","avatar":"https://avatars.githubusercontent.com/u/32073?v=4"},"body":"Add --no-check option to git-write-tree.\n\nSigned-off-by: Bryan Larsen <bryan.larsen@gmail.com>\n---\n\n  Documentation/git-write-tree.txt |    6 ++++++\n  write-tree.c                     |   14 +++++++++++++-\n  2 files changed, 19 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-write-tree.txt \nb/Documentation/git-write-tree.txt\n--- a/Documentation/git-write-tree.txt\n+++ b/Documentation/git-write-tree.txt\n@@ -10,6 +10,7 @@ git-write-tree - Creates a tree from the\n  SYNOPSIS\n  --------\n  'git-write-tree'\n+\t\t[--no-check]\n\n  DESCRIPTION\n  -----------\n@@ -23,6 +24,11 @@ In order to have that match what is actu\n  now, you need to have done a \"git-update-cache\" phase before you did the\n  \"git-write-tree\".\n\n+OPTIONS\n+-------\n+--no-check::\n+\tNormally \"git-write-tree\" ensures that the objects referenced by the\n+\tdirectory exist in the object database.  This option disabled this check.\n\n\n\ndiff --git a/write-tree.c b/write-tree.c\n--- a/write-tree.c\n+++ b/write-tree.c\n@@ -5,6 +5,8 @@\n   */\n  #include \"cache.h\"\n\n+static int no_check = 0;\n+\n  static int check_valid_sha1(unsigned char *sha1)\n  {\n  \tint ret;\n@@ -61,7 +63,7 @@ static int write_tree(struct cache_entry\n  \t\t\tsha1 = subdir_sha1;\n  \t\t}\n\n-\t\tif (check_valid_sha1(sha1) < 0)\n+\t\tif (!no_check && check_valid_sha1(sha1) < 0)\n  \t\t\texit(1);\n\n  \t\tentrylen = pathlen - baselen;\n@@ -86,6 +88,16 @@ int main(int argc, char **argv)\n  \tint i, funny;\n  \tint entries = read_cache();\n  \tunsigned char sha1[20];\n+\t\n+\tif (argc==2) {\n+\t\tif (!strcmp(argv[1], \"--no-check\"))\n+\t\t\tno_check = 1;\n+\t\telse\n+\t\t\tdie(\"unknown option %s\", argv[1]);\n+\t}\n+\t\n+\tif (argc>2)\n+\t\tdie(\"too many options\");\n\n  \tif (entries < 0)\n  \t\tdie(\"git-write-tree: error reading cache\");\n\n\n\f\n"},{"id":"5831","messageId":"Pine.LNX.4.58.0507081238370.17536@g5.osdl.org","threadId":"1165","inReplyTo":"42CE577C.1070404@gmail.com","subject":"Re: [PATCH] add --no-check option to git-write-tree","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-07-08T19:42:00Z","receivedAt":"2005-07-08T19:42:00Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 8 Jul 2005, Bryan Larsen wrote:\n>\n> Add --no-check option to git-write-tree.\n\nI like almost all of these patches (well, the ones relevant to core git,\nI'll not speak for Pasky on cogito), although I'd actually prefer your\n\"index_fd()\" info-only flag to work the other way around: make it a flag\nto say whether to update the object directory or not (ie \"0\" means info\nonly, and \"1\" means the current \"update object directory\" - and name it\naccordingly, of course).\n\nHowever, your mailer - apparently\n\n\tUser-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317)\n\nis totally broken and does strange white-space corruption, so none of the \npatches would apply. \n\nSo can you fix that up and re-send (and cc me on the git part)?\n\n\t\tLinus\n"}]}