Skip to content

Commit 3295c35

Browse files
jltoblergitster
authored andcommitted
rev-list: extend print-info to print missing object type
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 <[email protected]> Acked-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c6d896b commit 3295c35

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Documentation/rev-list-options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,9 @@ one of the following:
10381038
* The `path=<path>` shows the path of the missing object inferred from a
10391039
containing object. A path containing SP or special characters is enclosed in
10401040
double-quotes in the C style as needed.
1041+
+
1042+
* The `type=<type>` shows the type of the missing object inferred from a
1043+
containing object.
10411044
--
10421045
+
10431046
If some tips passed to the traversal are missing, they will be

builtin/rev-list.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ static int arg_print_omitted; /* print objects omitted by filter */
7979
struct missing_objects_map_entry {
8080
struct oidmap_entry entry;
8181
const char *path;
82+
unsigned type;
8283
};
8384
static struct oidmap missing_objects;
8485
enum missing_action {
@@ -109,7 +110,8 @@ static off_t get_object_disk_usage(struct object *obj)
109110
return size;
110111
}
111112

112-
static void add_missing_object_entry(struct object_id *oid, const char *path)
113+
static void add_missing_object_entry(struct object_id *oid, const char *path,
114+
unsigned type)
113115
{
114116
struct missing_objects_map_entry *entry;
115117

@@ -118,6 +120,7 @@ static void add_missing_object_entry(struct object_id *oid, const char *path)
118120

119121
CALLOC_ARRAY(entry, 1);
120122
entry->entry.oid = *oid;
123+
entry->type = type;
121124
if (path)
122125
entry->path = xstrdup(path);
123126
oidmap_put(&missing_objects, entry);
@@ -142,6 +145,8 @@ static void print_missing_object(struct missing_objects_map_entry *entry,
142145

143146
strbuf_release(&path);
144147
}
148+
if (entry->type)
149+
strbuf_addf(&sb, " type=%s", type_name(entry->type));
145150

146151
printf("?%s%s\n", oid_to_hex(&entry->entry.oid), sb.buf);
147152
strbuf_release(&sb);
@@ -166,7 +171,7 @@ static inline void finish_object__ma(struct object *obj, const char *name)
166171

167172
case MA_PRINT:
168173
case MA_PRINT_INFO:
169-
add_missing_object_entry(&obj->oid, name);
174+
add_missing_object_entry(&obj->oid, name, obj->type);
170175
return;
171176

172177
case MA_ALLOW_PROMISOR:
@@ -843,7 +848,7 @@ int cmd_rev_list(int argc,
843848

844849
/* Add missing tips */
845850
while ((oid = oidset_iter_next(&iter)))
846-
add_missing_object_entry(oid, NULL);
851+
add_missing_object_entry(oid, NULL, 0);
847852

848853
oidset_clear(&revs.missing_commits);
849854
}

t/t6022-rev-list-missing.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ do
164164
165165
oid="$(git rev-parse "$obj")" &&
166166
path=".git/objects/$(test_oid_to_path $oid)" &&
167+
type_info=" type=$(git cat-file -t $oid)" &&
167168
168169
case $obj in
169170
HEAD:foo)
@@ -184,7 +185,7 @@ do
184185
# get the expected oids.
185186
git rev-list --objects --no-object-names \
186187
HEAD ^"$obj" >expect.raw &&
187-
echo "?$oid$path_info" >>expect.raw &&
188+
echo "?$oid$path_info$type_info" >>expect.raw &&
188189
189190
mv "$path" "$path.hidden" &&
190191
git rev-list --objects --no-object-names \

0 commit comments

Comments
 (0)