diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-05-17 20:11:41 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-05-17 20:11:41 +0300 |
commit | 67a3b2b39f638872531324e03217fa58f7b9ad1e (patch) | |
tree | 5c4e9c7b9e2c0efc9c9f9e7e70fb11b104f95890 /builtin | |
parent | 3307f7dde2ae8f5281d0782f7291a073c9b1cdc2 (diff) | |
parent | 44451a2e5eec5360378be23e2cdbd9ecee49e14e (diff) |
Merge branch 'jc/attr-source-tree'
"git --attr-source=<tree> cmd $args" is a new way to have any
command to read attributes not from the working tree but from the
given tree object.
* jc/attr-source-tree:
attr: teach "--attr-source=<tree>" global option to "git"
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/check-attr.c | 17 | ||||
-rw-r--r-- | builtin/pack-objects.c | 2 |
2 files changed, 9 insertions, 10 deletions
diff --git a/builtin/check-attr.c b/builtin/check-attr.c index b2b678847f..e27b86d150 100644 --- a/builtin/check-attr.c +++ b/builtin/check-attr.c @@ -64,7 +64,7 @@ static void output_attr(struct attr_check *check, const char *file) } static void check_attr(const char *prefix, struct attr_check *check, - const struct object_id *tree_oid, int collect_all, + int collect_all, const char *file) { @@ -72,9 +72,9 @@ static void check_attr(const char *prefix, struct attr_check *check, prefix_path(prefix, prefix ? strlen(prefix) : 0, file); if (collect_all) { - git_all_attrs(&the_index, tree_oid, full_path, check); + git_all_attrs(&the_index, full_path, check); } else { - git_check_attr(&the_index, tree_oid, full_path, check); + git_check_attr(&the_index, full_path, check); } output_attr(check, file); @@ -82,7 +82,7 @@ static void check_attr(const char *prefix, struct attr_check *check, } static void check_attr_stdin_paths(const char *prefix, struct attr_check *check, - const struct object_id *tree_oid, int collect_all) + int collect_all) { struct strbuf buf = STRBUF_INIT; struct strbuf unquoted = STRBUF_INIT; @@ -96,7 +96,7 @@ static void check_attr_stdin_paths(const char *prefix, struct attr_check *check, die("line is badly quoted"); strbuf_swap(&buf, &unquoted); } - check_attr(prefix, check, tree_oid, collect_all, buf.buf); + check_attr(prefix, check, collect_all, buf.buf); maybe_flush_or_die(stdout, "attribute to stdout"); } strbuf_release(&buf); @@ -112,7 +112,6 @@ static NORETURN void error_with_usage(const char *msg) int cmd_check_attr(int argc, const char **argv, const char *prefix) { struct attr_check *check; - struct object_id *tree_oid = NULL; struct object_id initialized_oid; int cnt, i, doubledash, filei; @@ -188,14 +187,14 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix) if (source) { if (repo_get_oid_tree(the_repository, source, &initialized_oid)) die("%s: not a valid tree-ish source", source); - tree_oid = &initialized_oid; + set_git_attr_source(source); } if (stdin_paths) - check_attr_stdin_paths(prefix, check, tree_oid, all_attrs); + check_attr_stdin_paths(prefix, check, all_attrs); else { for (i = filei; i < argc; i++) - check_attr(prefix, check, tree_oid, all_attrs, argv[i]); + check_attr(prefix, check, all_attrs, argv[i]); maybe_flush_or_die(stdout, "attribute to stdout"); } diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index a5b466839b..9cfc8801f9 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1331,7 +1331,7 @@ static int no_try_delta(const char *path) if (!check) check = attr_check_initl("delta", NULL); - git_check_attr(the_repository->index, NULL, path, check); + git_check_attr(the_repository->index, path, check); if (ATTR_FALSE(check->items[0].value)) return 1; return 0; |