[PATCH 2/3] update-index --{set,get}-base

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <junkio@xxxxxxx>
---
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 71cef63..5ed7c63 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -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);
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index cd5e014..79c4e6e 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -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.
 

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]