git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/9] update-index: add --checkout/--no-checkout options to update CE_NO_CHECKOUT bit

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Aug 15, 2008, 14:25 UTC
Message-ID
<20080815142515.GA10667@laptop>
In-Reply-To
<cover.1218807249.git.pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin-update-index.c |   40 +++++++++++++++++++++++++---------------
 1 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 434cb8e..1d6bb65 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -24,8 +24,9 @@ static int info_only;
 static int force_remove;
 static int verbose;
 static int mark_valid_only;
-#define MARK_VALID 1
-#define UNMARK_VALID 2
+static int mark_no_checkout_only;
+#define MARK_FLAG 1
+#define UNMARK_FLAG 2
 
 static void report(const char *fmt, ...)
 {
@@ -40,19 +41,15 @@ static void report(const char *fmt, ...)
 	va_end(vp);
 }
 
-static int mark_valid(const char *path)
+static int mark_ce_flags(const char *path, int flag, int mark)
 {
 	int namelen = strlen(path);
 	int pos = cache_name_pos(path, namelen);
 	if (0 <= pos) {
-		switch (mark_valid_only) {
-		case MARK_VALID:
-			active_cache[pos]->ce_flags |= CE_VALID;
-			break;
-		case UNMARK_VALID:
-			active_cache[pos]->ce_flags &= ~CE_VALID;
-			break;
-		}
+		if (mark)
+			active_cache[pos]->ce_flags |= flag;
+		else
+			active_cache[pos]->ce_flags &= ~flag;
 		cache_tree_invalidate_path(active_cache_tree, path);
 		active_cache_changed = 1;
 		return 0;
@@ -276,7 +273,12 @@ static void update_one(const char *path, const char *prefix, int prefix_length)
 		goto free_return;
 	}
 	if (mark_valid_only) {
-		if (mark_valid(p))
+		if (mark_ce_flags(p, CE_VALID, mark_valid_only == MARK_FLAG))
+			die("Unable to mark file %s", path);
+		goto free_return;
+	}
+	if (mark_no_checkout_only) {
+		if (mark_ce_flags(p, CE_NO_CHECKOUT, mark_no_checkout_only == MARK_FLAG))
 			die("Unable to mark file %s", path);
 		goto free_return;
 	}
@@ -390,7 +392,7 @@ static void read_index_info(int line_termination)
 }
 
 static const char update_index_usage[] =
-"git update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>...";
+"git update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--checkout|--no-checkout] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>...";
 
 static unsigned char head_sha1[20];
 static unsigned char merge_head_sha1[20];
@@ -647,11 +649,19 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 				continue;
 			}
 			if (!strcmp(path, "--assume-unchanged")) {
-				mark_valid_only = MARK_VALID;
+				mark_valid_only = MARK_FLAG;
 				continue;
 			}
 			if (!strcmp(path, "--no-assume-unchanged")) {
-				mark_valid_only = UNMARK_VALID;
+				mark_valid_only = UNMARK_FLAG;
+				continue;
+			}
+			if (!strcmp(path, "--checkout")) {
+				mark_no_checkout_only = UNMARK_FLAG;
+				continue;
+			}
+			if (!strcmp(path, "--no-checkout")) {
+				mark_no_checkout_only = MARK_FLAG;
 				continue;
 			}
 			if (!strcmp(path, "--info-only")) {
-- 
1.6.0.rc3.250.g8dd0
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 2 of 9 in “Introduce CE_NO_CHECKOUT bit”
  1. 1/9 Introduce CE_NO_CHECKOUT bitNguyễn Thái Ngọc Duy, Aug 15, 2008
  2. 2/9 update-index: add --checkout/--no-checkout options to update CE_NO_CHECKOUT bitNguyễn Thái Ngọc Duy, Aug 15, 2008
  3. 3/9 ls-files: add --checkout option to show checked out filesNguyễn Thái Ngọc Duy, Aug 15, 2008
  4. 4/9 Prevent diff machinery from examining worktree outside narrow checkoutNguyễn Thái Ngọc Duy, Aug 15, 2008
  5. 5/9 Clear CE_NO_CHECKOUT on checked out entries.Nguyễn Thái Ngọc Duy, Aug 15, 2008
  6. 6/9 Add support for narrow checkout in unpack_trees()Nguyễn Thái Ngọc Duy, Aug 15, 2008
  7. 7/9 ls-files: add --narrow-match=spec option to test narrow matchingNguyễn Thái Ngọc Duy, Aug 15, 2008
  8. 8/9 clone: support narrow checkout with --path optionNguyễn Thái Ngọc Duy, Aug 15, 2008
  9. 9/9 checkout: add new options to support narrow checkoutNguyễn Thái Ngọc Duy, Aug 15, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.