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

[PATCH 5/6] Teach --id to "git rm"

From
Nazri Ramliy <ayiehere@gmail.com>
Date
Aug 5, 2009, 09:51 UTC
Message-ID
<1249465906-3940-6-git-send-email-ayiehere@gmail.com>
In-Reply-To
<1249465906-3940-5-git-send-email-ayiehere@gmail.com>
---
 builtin-rm.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/builtin-rm.c b/builtin-rm.c
index 57975db..d2982a0 100644
--- a/builtin-rm.c
+++ b/builtin-rm.c
@@ -137,6 +137,7 @@ static struct lock_file lock_file;
 
 static int show_only = 0, force = 0, index_only = 0, recursive = 0, quiet = 0;
 static int ignore_unmatch = 0;
+static const char *file_id;
 
 static struct option builtin_rm_options[] = {
 	OPT__DRY_RUN(&show_only),
@@ -146,6 +147,7 @@ static struct option builtin_rm_options[] = {
 	OPT_BOOLEAN('r', NULL,             &recursive,  "allow recursive removal"),
 	OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch,
 				"exit with a zero status even if nothing matched"),
+	OPT_STRING('d', "id", &file_id, "FILE_ID", "file id"),
 	OPT_END(),
 };
 
@@ -154,11 +156,18 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 	int i, newfd;
 	const char **pathspec;
 	char *seen;
+	char **new_argv;
 
 	git_config(git_default_config, NULL);
 
 	argc = parse_options(argc, argv, prefix, builtin_rm_options,
 			     builtin_rm_usage, 0);
+
+	if (file_id)
+		new_argv = (char **) expand_file_ids(file_id, &argc, (char **) argv);
+	else
+		new_argv = (char **) argv;
+
 	if (!argc)
 		usage_with_options(builtin_rm_usage, builtin_rm_options);
 
@@ -171,7 +180,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 		die("index file corrupt");
 	refresh_cache(REFRESH_QUIET);
 
-	pathspec = get_pathspec(prefix, argv);
+	pathspec = get_pathspec(prefix, (const char **) new_argv);
 	seen = NULL;
 	for (i = 0; pathspec[i] ; i++)
 		/* nothing */;
-- 
1.6.4.13.ge6580
Previous: Nazri RamliyNext: Nazri Ramliy
Message 6 of 17 in “RFC - Say goodbye to the rodent”
  1. RFC - Say goodbye to the rodentNazri Ramliy, Aug 5, 2009
  2. 1/6 Teach --id/-d to "git status"Nazri Ramliy, Aug 5, 2009
  3. 2/6 Teach --id to "git add"Nazri Ramliy, Aug 5, 2009
  4. 3/6 Teach --id to "git checkout"Nazri Ramliy, Aug 5, 2009
  5. 4/6 Teach --d to "git commit"Nazri Ramliy, Aug 5, 2009
  6. 5/6 Teach --id to "git rm"Nazri Ramliy, Aug 5, 2009
  7. 6/6 Teach --id to "git reset"Nazri Ramliy, Aug 5, 2009
  8. Alex RiesenAug 5, 2009
  9. Sverre RabbelierAug 5, 2009
  10. Junio C HamanoAug 5, 2009
  11. Sverre RabbelierAug 5, 2009
  12. Alex RiesenAug 5, 2009
  13. Sverre RabbelierAug 5, 2009
  14. Andreas EricssonAug 5, 2009
  15. Matthieu MoyAug 5, 2009
  16. Jeff KingAug 5, 2009
  17. Nicolas PitreAug 5, 2009

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.