Merge branch 'es/rev-list-no-object-names'
"git rev-list --objects" learned with "--no-object-names" option to squelch the path to the object that is used as a grouping hint for pack-objects. * es/rev-list-no-object-names: rev-list: teach --no-object-names to enable piping
This commit is contained in:
commit
f4f7e75ad5
@ -48,6 +48,7 @@ SYNOPSIS
|
|||||||
[ --date=<format>]
|
[ --date=<format>]
|
||||||
[ [ --objects | --objects-edge | --objects-edge-aggressive ]
|
[ [ --objects | --objects-edge | --objects-edge-aggressive ]
|
||||||
[ --unpacked ]
|
[ --unpacked ]
|
||||||
|
[ --object-names | --no-object-names ]
|
||||||
[ --filter=<filter-spec> [ --filter-print-omitted ] ] ]
|
[ --filter=<filter-spec> [ --filter-print-omitted ] ] ]
|
||||||
[ --missing=<missing-action> ]
|
[ --missing=<missing-action> ]
|
||||||
[ --pretty | --header ]
|
[ --pretty | --header ]
|
||||||
|
@ -708,6 +708,16 @@ ifdef::git-rev-list[]
|
|||||||
Only useful with `--objects`; print the object IDs that are not
|
Only useful with `--objects`; print the object IDs that are not
|
||||||
in packs.
|
in packs.
|
||||||
|
|
||||||
|
--object-names::
|
||||||
|
Only useful with `--objects`; print the names of the object IDs
|
||||||
|
that are found. This is the default behavior.
|
||||||
|
|
||||||
|
--no-object-names::
|
||||||
|
Only useful with `--objects`; does not print the names of the object
|
||||||
|
IDs that are found. This inverts `--object-names`. This flag allows
|
||||||
|
the output to be more easily parsed by commands such as
|
||||||
|
linkgit:git-cat-file[1].
|
||||||
|
|
||||||
--filter=<filter-spec>::
|
--filter=<filter-spec>::
|
||||||
Only useful with one of the `--objects*`; omits objects (usually
|
Only useful with one of the `--objects*`; omits objects (usually
|
||||||
blobs) from the list of printed objects. The '<filter-spec>'
|
blobs) from the list of printed objects. The '<filter-spec>'
|
||||||
|
@ -49,6 +49,7 @@ static const char rev_list_usage[] =
|
|||||||
" --objects | --objects-edge\n"
|
" --objects | --objects-edge\n"
|
||||||
" --unpacked\n"
|
" --unpacked\n"
|
||||||
" --header | --pretty\n"
|
" --header | --pretty\n"
|
||||||
|
" --[no-]object-names\n"
|
||||||
" --abbrev=<n> | --no-abbrev\n"
|
" --abbrev=<n> | --no-abbrev\n"
|
||||||
" --abbrev-commit\n"
|
" --abbrev-commit\n"
|
||||||
" --left-right\n"
|
" --left-right\n"
|
||||||
@ -75,6 +76,9 @@ enum missing_action {
|
|||||||
};
|
};
|
||||||
static enum missing_action arg_missing_action;
|
static enum missing_action arg_missing_action;
|
||||||
|
|
||||||
|
/* display only the oid of each object encountered */
|
||||||
|
static int arg_show_object_names = 1;
|
||||||
|
|
||||||
#define DEFAULT_OIDSET_SIZE (16*1024)
|
#define DEFAULT_OIDSET_SIZE (16*1024)
|
||||||
|
|
||||||
static void finish_commit(struct commit *commit);
|
static void finish_commit(struct commit *commit);
|
||||||
@ -255,7 +259,10 @@ static void show_object(struct object *obj, const char *name, void *cb_data)
|
|||||||
display_progress(progress, ++progress_counter);
|
display_progress(progress, ++progress_counter);
|
||||||
if (info->flags & REV_LIST_QUIET)
|
if (info->flags & REV_LIST_QUIET)
|
||||||
return;
|
return;
|
||||||
show_object_with_name(stdout, obj, name);
|
if (arg_show_object_names)
|
||||||
|
show_object_with_name(stdout, obj, name);
|
||||||
|
else
|
||||||
|
printf("%s\n", oid_to_hex(&obj->oid));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_edge(struct commit *commit)
|
static void show_edge(struct commit *commit)
|
||||||
@ -484,6 +491,16 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
|
|||||||
if (skip_prefix(arg, "--missing=", &arg))
|
if (skip_prefix(arg, "--missing=", &arg))
|
||||||
continue; /* already handled above */
|
continue; /* already handled above */
|
||||||
|
|
||||||
|
if (!strcmp(arg, ("--no-object-names"))) {
|
||||||
|
arg_show_object_names = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(arg, ("--object-names"))) {
|
||||||
|
arg_show_object_names = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
usage(rev_list_usage);
|
usage(rev_list_usage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,26 @@ test_expect_success 'rev-list --objects with pathspecs and copied files' '
|
|||||||
! grep one output
|
! grep one output
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rev-list --objects --no-object-names has no space/names' '
|
||||||
|
git rev-list --objects --no-object-names HEAD >output &&
|
||||||
|
! grep wanted_file output &&
|
||||||
|
! grep unwanted_file output &&
|
||||||
|
! grep " " output
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rev-list --objects --no-object-names works with cat-file' '
|
||||||
|
git rev-list --objects --no-object-names --all >list-output &&
|
||||||
|
git cat-file --batch-check <list-output >cat-output &&
|
||||||
|
! grep missing cat-output
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success '--no-object-names and --object-names are last-one-wins' '
|
||||||
|
git rev-list --objects --no-object-names --object-names --all >output &&
|
||||||
|
grep wanted_file output &&
|
||||||
|
git rev-list --objects --object-names --no-object-names --all >output &&
|
||||||
|
! grep wanted_file output
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'rev-list A..B and rev-list ^A B are the same' '
|
test_expect_success 'rev-list A..B and rev-list ^A B are the same' '
|
||||||
git commit --allow-empty -m another &&
|
git commit --allow-empty -m another &&
|
||||||
git tag -a -m "annotated" v1.0 &&
|
git tag -a -m "annotated" v1.0 &&
|
||||||
|
Loading…
Reference in New Issue
Block a user