{"thread":{"id":"7468","subject":"[PATCH 2/3] update-index --{set,get}-base","startedAt":"2007-03-29T08:23:11Z","lastAt":"2007-03-29T08:23:11Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"38292","messageId":"7vhcs44fww.fsf@assigned-by-dhcp.cox.net","threadId":"7468","inReplyTo":null,"subject":"[PATCH 2/3] update-index --{set,get}-base","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-29T08:23:11Z","receivedAt":"2007-03-29T08:23:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"These new options allow scripts to interact with BASE index\nextension.  The scripts would store HEAD information when\nchecking a revision out, and extract and check it when making a\nnew commit.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\ndiff --git a/builtin-update-index.c b/builtin-update-index.c\nindex 71cef63..5ed7c63 100644\n--- a/builtin-update-index.c\n+++ b/builtin-update-index.c\n@@ -617,6 +617,23 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\t\t\tverbose = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(path, \"--set-base\")) {\n+\t\t\t\tunsigned char sha1[20];\n+\t\t\t\tif (argc <= ++i)\n+\t\t\t\t\tdie(\"git-update-index: --set-base <sha1>\");\n+\t\t\t\tif (get_sha1_hex(argv[i], sha1))\n+\t\t\t\t\tdie(\"git-update-index: --set-base: malformed object name '%s'\", argv[i]);\n+\t\t\t\tactive_cache_changed = 1;\n+\t\t\t\tactive_cache_base_valid = 1;\n+\t\t\t\thashcpy(active_cache_base, sha1);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tif (!strcmp(path, \"--get-base\")) {\n+\t\t\t\tif (active_cache_base_valid)\n+\t\t\t\t\tprintf(\"%s\\n\",\n+\t\t\t\t\t       sha1_to_hex(active_cache_base));\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(path, \"-h\") || !strcmp(path, \"--help\"))\n \t\t\t\tusage(update_index_usage);\n \t\t\tdie(\"unknown option %s\", path);\ndiff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt\nindex cd5e014..79c4e6e 100644\n--- a/Documentation/git-update-index.txt\n+++ b/Documentation/git-update-index.txt\n@@ -17,6 +17,7 @@ SYNOPSIS\n \t     [--assume-unchanged | --no-assume-unchanged]\n \t     [--really-refresh] [--unresolve] [--again | -g]\n \t     [--info-only] [--index-info]\n+\t     [--get-base] [--set-base <base>]\n \t     [-z] [--stdin]\n \t     [--verbose]\n \t     [--] [<file>]\\*\n@@ -110,6 +111,17 @@ OPTIONS\n \tread list of paths from the standard input.  Paths are\n \tseparated by LF (i.e. one path per line) by default.\n \n+--get-base::\n+\tThe index can record which commit object its state was\n+\tinitialized from (hence expected to have as the first\n+\tparent commit for the next commit).  This option reads\n+\tthe commit object name and writes it to the standard\n+\toutput.\n+\n+--set-base <base>::\n+\tThis option records the commit object name in the index,\n+\tlater to be retrieved with the `--get-base` option.\n+\n --verbose::\n         Report what is being added and removed from index.\n \n"}]}