{"thread":{"id":"1167","subject":"[PATCH] 3/7 Add --info-only option to git-update-cache.","startedAt":"2005-07-08T10:54:24Z","lastAt":"2005-07-08T10:54:24Z","messageCount":1,"participants":["Bryan Larsen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"5817","messageId":"42CE5B60.8050500@gmail.com","threadId":"1167","inReplyTo":null,"subject":"[PATCH] 3/7 Add --info-only option to git-update-cache.","fromName":"Bryan Larsen","fromEmail":"bryan.larsen@gmail.com","sentAt":"2005-07-08T10:54:24Z","receivedAt":"2005-07-08T10:54:24Z","isPatch":true,"sender":{"key":"bryan@larsen.st","avatar":"https://avatars.githubusercontent.com/u/32073?v=4"},"body":"\n\nAdd --info-only option to git-update-cache.\n\nSigned-off-by: Bryan Larsen <bryan.larsen@gmail.com>\n---\n\n  Documentation/git-update-cache.txt |   23 +++++++++++++++++++----\n  update-cache.c                     |   14 +++++++++++---\n  2 files changed, 30 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-update-cache.txt \nb/Documentation/git-update-cache.txt\n--- a/Documentation/git-update-cache.txt\n+++ b/Documentation/git-update-cache.txt\n@@ -14,6 +14,7 @@ SYNOPSIS\n  \t     [--ignore-missing]\n  \t     [--force-remove]\n  \t     [--cacheinfo <mode> <object> <file>]\\*\n+\t     [--info-only]\n  \t     [--] [<file>]\\*\n\n  DESCRIPTION\n@@ -47,6 +48,9 @@ OPTIONS\n  --cacheinfo <mode> <object> <path>::\n  \tDirectly insert the specified info into the cache.\n  \t\n+--info-only::\n+\tAll <file> arguments behave like --cacheinfo.\n+\t\n  --force-remove::\n  \tRemove the file from the index even when the working directory\n  \tstill has such a file. (Implies --remove.)\n@@ -80,15 +84,26 @@ the stat entry is out of date.\n  For example, you'd want to do this after doing a \"git-read-tree\", to link\n  up the stat cache details with the proper files.\n\n-Using --cacheinfo\n------------------\n-'--cacheinfo' is used to register a file that is not in the current\n-working directory.  This is useful for minimum-checkout merging.\n+Using --cacheinfo or --info-only\n+--------------------------------\n+'--cacheinfo' is used to register a file that is not in the current \nworking\n+directory.  This is useful for minimum-checkout merging.\n\n  To pretend you have a file with mode and sha1 at path, say:\n\n   $ git-update-cache --cacheinfo mode sha1 path\n+\n+'--info-only' is used to register a file without placing it in the object\n+database.  This is useful for status-only repositories.\n+\n+Both '--cacheinfo' and '--info-only' behave similarly: the index is updated\n+but the object database isn't.  '--cacheinfo' is useful when the object is\n+in the database but the file isn't available locally.  '--info-only' is\n+useful when the file is available, but you do not wish to update the \nobject\n+database.\n\n+Examples\n+--------\n  To update and refresh only the files already checked out:\n\n     git-checkout-cache -n -f -a && git-update-cache --ignore-missing \n--refresh\ndiff --git a/update-cache.c b/update-cache.c\n--- a/update-cache.c\n+++ b/update-cache.c\n@@ -12,7 +12,7 @@\n   * like \"git-update-cache *\" and suddenly having all the object\n   * files be revision controlled.\n   */\n-static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new \n= 0, quiet = 0;\n+static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new \n= 0, quiet = 0, info_only = 0;\n  static int force_remove;\n\n  /* Three functions to allow overloaded pointer return; see linux/err.h */\n@@ -68,7 +68,7 @@ static int add_file_to_cache(char *path)\n  \t\tfd = open(path, O_RDONLY);\n  \t\tif (fd < 0)\n  \t\t\treturn -1;\n-\t\tif (index_fd(ce->sha1, fd, &st, 0) < 0)\n+\t\tif (index_fd(ce->sha1, fd, &st, info_only) < 0)\n  \t\t\treturn -1;\n  \t\tbreak;\n  \tcase S_IFLNK:\n@@ -77,7 +77,11 @@ static int add_file_to_cache(char *path)\n  \t\t\tfree(target);\n  \t\t\treturn -1;\n  \t\t}\n-\t\tif (write_sha1_file(target, st.st_size, \"blob\", ce->sha1))\n+\t\tif (info_only) {\n+\t\t\tunsigned char hdr[50];\n+\t\t\tint hdrlen;\n+\t\t\twrite_sha1_file_prepare(target, st.st_size, \"blob\", ce->sha1, hdr, \n&hdrlen);\n+\t\t} else if (write_sha1_file(target, st.st_size, \"blob\", ce->sha1))\n  \t\t\treturn -1;\n  \t\tfree(target);\n  \t\tbreak;\n@@ -382,6 +386,10 @@ int main(int argc, char **argv)\n  \t\t\t\ti += 3;\n  \t\t\t\tcontinue;\n  \t\t\t}\n+\t\t\tif (!strcmp(path, \"--info-only\")) {\n+\t\t\t\tinfo_only = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n  \t\t\tif (!strcmp(path, \"--force-remove\")) {\n  \t\t\t\tforce_remove = 1;\n  \t\t\t\tcontinue;\n\n\n\f\n"}]}