update-index --{set,get}-base
PATCH 2/3 update-index --{set,get}-base
These new options allow scripts to interact with BASE index extension. The scripts would store HEAD information when checking a revision out, and extract and check it when making a new commit.
Signed-off-by Junio C Hamano <[email protected]>
---
builtin-update-index.c +17 -0
@@ -617,6 +617,23 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) verbose =1 ;continue ; } +if (!strcmp (path,"--set-base" )) { +unsigned char sha1[20 ]; +if (argc <= ++i) +die ("git-update-index: --set-base <sha1>" ); +if (get_sha1_hex (argv[i], sha1)) +die ("git-update-index: --set-base: malformed object name '%s'" , argv[i]); + active_cache_changed =1 ; + active_cache_base_valid =1 ; +hashcpy (active_cache_base, sha1); +continue ; + } +if (!strcmp (path,"--get-base" )) { +if (active_cache_base_valid) +printf ("%s\n" , +sha1_to_hex (active_cache_base)); +continue ; + }if (!strcmp (path,"-h" ) || !strcmp (path,"--help" ))usage (update_index_usage);die ("unknown option %s" , path);
Documentation/git-update-index.txt +12 -0
@@ -17,6 +17,7 @@ SYNOPSIS [--assume-unchanged | --no-assume-unchanged] [--really-refresh] [--unresolve] [--again | -g] [--info-only] [--index-info] + [--get-base] [--set-base <base>] [-z] [--stdin] [--verbose] [--] [<file>]\*
@@ -110,6 +111,17 @@ OPTIONS read list of paths from the standard input. Paths are separated by LF (i.e. one path per line) by default. +--get-base:: + The index can record which commit object its state was + initialized from (hence expected to have as the first + parent commit for the next commit). This option reads + the commit object name and writes it to the standard + output. + +--set-base <base>:: + This option records the commit object name in the index, + later to be retrieved with the `--get-base` option. + --verbose:: Report what is being added and removed from index.