From: Justin Tobler <jltobler@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, Justin Tobler <jltobler@gmail.com>
Subject: [PATCH v3 4/4] rev-list: extend print-info to print missing object type
Date: Sat, 1 Feb 2025 14:16:58 -0600 [thread overview]
Message-ID: <20250201201658.11562-5-jltobler@gmail.com> (raw)
In-Reply-To: <20250201201658.11562-1-jltobler@gmail.com>
Additional information about missing objects found in git-rev-list(1)
can be printed by specifying the `print-info` missing action for the
`--missing` option. Extend this action to also print missing object type
information inferred from its containing object. This token follows the
form `type=<type>` and specifies the expected object type of the missing
object.
Signed-off-by: Justin Tobler <jltobler@gmail.com>
---
Documentation/rev-list-options.txt | 3 +++
builtin/rev-list.c | 11 ++++++++---
t/t6022-rev-list-missing.sh | 3 ++-
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index 0bea9d4ad3..f10f78c600 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -1038,6 +1038,9 @@ one of the following:
* The `path=<path>` shows the path of the missing object inferred from a
containing object. A path containing SP or special characters is enclosed in
double-quotes in the C style as needed.
++
+* The `type=<type>` shows the type of the missing object inferred from a
+ containing object.
--
+
If some tips passed to the traversal are missing, they will be
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 4a45a4e555..963f96d031 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -79,6 +79,7 @@ static int arg_print_omitted; /* print objects omitted by filter */
struct missing_objects_map_entry {
struct oidmap_entry entry;
const char *path;
+ unsigned type;
};
static struct oidmap missing_objects;
enum missing_action {
@@ -109,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj)
return size;
}
-static void add_missing_object_entry(struct object_id *oid, const char *path)
+static void add_missing_object_entry(struct object_id *oid, const char *path,
+ unsigned type)
{
struct missing_objects_map_entry *entry;
@@ -118,6 +120,7 @@ static void add_missing_object_entry(struct object_id *oid, const char *path)
CALLOC_ARRAY(entry, 1);
entry->entry.oid = *oid;
+ entry->type = type;
if (path)
entry->path = xstrdup(path);
oidmap_put(&missing_objects, entry);
@@ -143,6 +146,8 @@ static void print_missing_object(struct missing_objects_map_entry *entry,
strbuf_release(&path);
}
+ if (entry->type)
+ strbuf_addf(&sb, " type=%s", type_name(entry->type));
printf("?%s%s\n", oid_to_hex(&entry->entry.oid), sb.buf);
strbuf_release(&sb);
@@ -167,7 +172,7 @@ static inline void finish_object__ma(struct object *obj, const char *name)
case MA_PRINT:
case MA_PRINT_INFO:
- add_missing_object_entry(&obj->oid, name);
+ add_missing_object_entry(&obj->oid, name, obj->type);
return;
case MA_ALLOW_PROMISOR:
@@ -844,7 +849,7 @@ int cmd_rev_list(int argc,
/* Add missing tips */
while ((oid = oidset_iter_next(&iter)))
- add_missing_object_entry(oid, NULL);
+ add_missing_object_entry(oid, NULL, 0);
oidset_clear(&revs.missing_commits);
}
diff --git a/t/t6022-rev-list-missing.sh b/t/t6022-rev-list-missing.sh
index 38afca6f09..3e2790d4c8 100755
--- a/t/t6022-rev-list-missing.sh
+++ b/t/t6022-rev-list-missing.sh
@@ -164,6 +164,7 @@ do
oid="$(git rev-parse "$obj")" &&
path=".git/objects/$(test_oid_to_path $oid)" &&
+ type_info=" type=$(git cat-file -t $oid)" &&
case $obj in
HEAD:foo)
@@ -184,7 +185,7 @@ do
# get the expected oids.
git rev-list --objects --no-object-names \
HEAD ^"$obj" >expect.raw &&
- echo "?$oid$path_info" >>expect.raw &&
+ echo "?$oid$path_info$type_info" >>expect.raw &&
mv "$path" "$path.hidden" &&
git rev-list --objects --no-object-names \
--
2.48.1.157.g3b0d05c4a7
next prev parent reply other threads:[~2025-02-01 20:20 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 3:40 [PATCH] rev-list: print missing object type with --missing=print-type Justin Tobler
2025-01-08 10:08 ` Christian Couder
2025-01-08 22:28 ` Justin Tobler
2025-01-08 15:17 ` Junio C Hamano
2025-01-08 22:18 ` Justin Tobler
2025-01-08 22:43 ` Junio C Hamano
2025-01-08 23:13 ` Justin Tobler
2025-01-10 5:34 ` [PATCH v2 0/2] rev-list: print additional missing object information Justin Tobler
2025-02-01 20:16 ` [PATCH v3 0/4] " Justin Tobler
2025-02-01 20:16 ` [PATCH v3 1/4] quote: add c quote flag to ignore core.quotePath Justin Tobler
2025-02-03 9:51 ` Christian Couder
2025-02-03 22:14 ` Junio C Hamano
2025-02-03 22:33 ` Junio C Hamano
2025-02-04 16:40 ` Junio C Hamano
2025-02-04 22:50 ` Justin Tobler
2025-02-01 20:16 ` [PATCH v3 2/4] quote: add quote_path() flag to ignore config Justin Tobler
2025-02-02 10:52 ` Phillip Wood
2025-02-04 22:39 ` Justin Tobler
2025-02-11 16:51 ` Phillip Wood
2025-02-03 10:07 ` Christian Couder
2025-02-03 22:52 ` Junio C Hamano
2025-02-01 20:16 ` [PATCH v3 3/4] rev-list: add print-info action to print missing object path Justin Tobler
2025-02-01 20:16 ` Justin Tobler [this message]
2025-02-03 10:45 ` [PATCH v3 0/4] rev-list: print additional missing object information Christian Couder
2025-02-04 22:51 ` Justin Tobler
2025-02-05 0:41 ` [PATCH v4 0/2] " Justin Tobler
2025-02-05 0:41 ` [PATCH v4 1/2] rev-list: add print-info action to print missing object path Justin Tobler
2025-02-05 0:41 ` [PATCH v4 2/2] rev-list: extend print-info to print missing object type Justin Tobler
2025-02-05 10:35 ` [PATCH v4 0/2] rev-list: print additional missing object information Christian Couder
2025-02-05 17:18 ` Justin Tobler
2025-02-05 13:18 ` Junio C Hamano
2025-02-05 17:17 ` Justin Tobler
2025-02-05 18:29 ` Junio C Hamano
2025-01-10 5:34 ` [PATCH v2 1/2] rev-list: add --missing-info to print missing object path Justin Tobler
2025-01-10 8:47 ` Christian Couder
2025-01-10 15:22 ` Junio C Hamano
2025-01-10 5:34 ` [PATCH v2 2/2] rev-list: extend --missing-info to print missing object type Justin Tobler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250201201658.11562-5-jltobler@gmail.com \
--to=jltobler@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.