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

[PATCH 2/4] missing: support rejecting --missing=print

From
Christian Couder <christian.couder@gmail.com>
Date
Apr 18, 2024, 18:40 UTC
Message-ID
<20240418184043.2900955-3-christian.couder@gmail.com>
In-Reply-To
<20240418184043.2900955-1-christian.couder@gmail.com>

`git pack-objects` supports the `--missing=<missing-action>` option in the same way as `git rev-list` except when '<missing-action>' is "print", which `git pack-objects` doesn't support.

As we want to refactor `git pack-objects` to use the same code from "missing.{c,h}" as `git rev-list` for the `--missing=...` feature, let's make it possible for that code to reject `--missing=print`.

`git pack-objects` will then use that code in a following commit.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 builtin/rev-list.c | 2 +-
 missing.c          | 4 ++--
 missing.h          | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index f71cc5ebe1..a712a6fd62 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -539,7 +539,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 			int res;
 			if (revs.exclude_promisor_objects)
 				die(_("options '%s' and '%s' cannot be used together"), "--exclude-promisor-objects", "--missing");
-			res = parse_missing_action_value(arg);
+			res = parse_missing_action_value(arg, 1);
 			if (res >= 0) {
 				arg_missing_action = res;
 				break;
diff --git a/missing.c b/missing.c
index 83e0c5e584..d306dea2d9 100644
--- a/missing.c
+++ b/missing.c
@@ -2,7 +2,7 @@
 #include "missing.h"
 #include "object-file.h"
 
-int parse_missing_action_value(const char *value)
+int parse_missing_action_value(const char *value, int print_ok)
 {
 	if (!strcmp(value, "error"))
 		return MA_ERROR;
@@ -12,7 +12,7 @@ int parse_missing_action_value(const char *value)
 		return MA_ALLOW_ANY;
 	}
 
-	if (!strcmp(value, "print")) {
+	if (!strcmp(value, "print") && print_ok) {
 		fetch_if_missing = 0;
 		return MA_PRINT;
 	}
diff --git a/missing.h b/missing.h
index c8261dfe55..77906691e7 100644
--- a/missing.h
+++ b/missing.h
@@ -13,6 +13,6 @@ enum missing_action {
   if parsing failed. Also sets the fetch_if_missing global variable
   from "object-file.h".
  */
-int parse_missing_action_value(const char *value);
+int parse_missing_action_value(const char *value, int print_ok);
 
 #endif /* MISSING_H */
-- 
2.44.0.655.g111bceeb19
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 13 in “upload-pack: support a missing-action”
  1. 0/4 upload-pack: support a missing-actionChristian Couder, Apr 18, 2024
  2. 1/4 rev-list: refactor --missing=<missing-action>Christian Couder, Apr 18, 2024
  3. Junio C HamanoApr 18, 2024
  4. 2/4 missing: support rejecting --missing=printChristian Couder, Apr 18, 2024
  5. Junio C HamanoApr 18, 2024
  6. 3/4 pack-objects: use the missing action APIChristian Couder, Apr 18, 2024
  7. 4/4 upload-pack: allow configuring a missing-actionChristian Couder, Apr 18, 2024
  8. Junio C HamanoApr 18, 2024
  9. 0/3 upload-pack: support a missing-actionChristian Couder, May 24, 2024
  10. 1/3 rev-list: refactor --missing=<missing-action>Christian Couder, May 24, 2024
  11. 2/3 pack-objects: use the missing action APIChristian Couder, May 24, 2024
  12. 3/3 upload-pack: allow configuring a missing-actionChristian Couder, May 24, 2024
  13. Junio C HamanoMay 24, 2024

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.