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

Re: [PATCHv2 6/7] builtin/describe.c: describe a blob

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 1, 2017, 04:11 UTC
Message-ID
<xmqqbmkmvdrq.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171031211852.13001-7-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
> +If the given object refers to a blob, it will be described
> +as `<commit-ish>:<path>`, such that the blob can be found
> +at `<path>` in the `<commit-ish>`. Note, that the commit is likely

Does the code describe a9dbc3f12c as v2.15.0:GIT-VERSION-GEN, or would it always be <commit>:<path>?

> +not the commit that introduced the blob, but the one that was found
> +first; to find the commit that introduced the blob, you need to find

Because we do not want to descend into the same tree object we saw earlier, this "we show the name we happened to find first without attempting to refine it for a better name" is a rather fundamental limitation of this approach. Hopefully we can later improve it with more thought, but for now it is better than nothing (and much better than "git log --raw | grep").

> +the commit that last touched the path, e.g.
> +`git log <commit-description> -- <path>`.
> +As blobs do not point at the commits they are contained in,
> +describing blobs is slow as we have to walk the whole graph.

Is it true that we walk the "whole graph", or do we stop immediately we find a path to the blob? The former makes it sound like completely useless.

> -#define SEEN		(1u << 0)
Interesting.  Now we include revision.h this becomes redundant.
Show 8 quoted lines
> +static void describe_blob(struct object_id oid, struct strbuf *dst)
> +{
> +	struct rev_info revs;
> +	struct argv_array args = ARGV_ARRAY_INIT;
> +	struct process_commit_data pcd = { null_oid, oid, dst};
> +
> +	argv_array_pushl(&args, "internal: The first arg is not parsed",
> +		"--all", "--reflog", /* as many starting points as possible */
Interesting.  

Do we also search in the reflog in the normal "describe" operation? If not, perhaps we should? I wonder what's the performance implications would be.

That tangent aside, as "describe blob" is most likely a "what reaches and is holding onto this blob?" query, finding something that can only be reached from a reflog entry would make it more helpful than without the option.

> +		/* NEEDSWORK: --all is incompatible with worktrees for now: */
What's that last colon about?
Show 16 quoted lines
> +		"--single-worktree",
> +		"--objects",
> +		"--in-commit-order",
> +		NULL);
> +
> +	init_revisions(&revs, NULL);
> +	if (setup_revisions(args.argc, args.argv, &revs, NULL) > 1)
> +		BUG("setup_revisions could not handle all args?");
> +
> +	if (prepare_revision_walk(&revs))
> +		die("revision walk setup failed");
> +
> +	traverse_commit_list(&revs, process_commit, process_object, &pcd);
> +	reset_revision_walk();
> +}
> +
OK.
Show 23 quoted lines
> diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
> index 1c0e8659d9..3be01316e8 100755
> --- a/t/t6120-describe.sh
> +++ b/t/t6120-describe.sh
> @@ -310,6 +310,21 @@ test_expect_success 'describe ignoring a borken submodule' '
>  	grep broken out
>  '
>  
> +test_expect_success 'describe a blob at a tag' '
> +	echo "make it a unique blob" >file &&
> +	git add file && git commit -m "content in file" &&
> +	git tag -a -m "latest annotated tag" unique-file &&
> +	git describe HEAD:file >actual &&
> +	echo "unique-file:file" >expect &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success 'describe a surviving blob' '
> +	git commit --allow-empty -m "empty commit" &&
> +	git describe HEAD:file >actual &&
> +	grep unique-file-1-g actual
> +'
> +

I am not sure what "surviving" means in this context. The word hinted that the test would be finding a blob that only appears in a commit that only appears as a reflog entry, but that wasn't the case, which was a bit disappointing.

Previous: Stefan BellerNext: Johannes Schindelin
Message 75 of 110 in “git-describe <blob> ?”
  1. 0/3 git-describe <blob> ?Stefan Beller, Oct 28, 2017
  2. 1/3 list-objects.c: factor out traverse_trees_and_blobsStefan Beller, Oct 28, 2017
  3. 2/3 revision.h: introduce blob/tree walking in order of the commitsStefan Beller, Oct 28, 2017
  4. Johannes SchindelinOct 28, 2017
  5. Stefan BellerOct 29, 2017
  6. Stefan BellerOct 29, 2017
  7. Junio C HamanoOct 29, 2017
  8. 3/3 builtin/describe: describe blobsStefan Beller, Oct 28, 2017
  9. Johannes SchindelinOct 28, 2017
  10. Jacob KellerOct 28, 2017
  11. Stefan BellerOct 29, 2017
  12. Kevin DaudtOct 29, 2017
  13. Johannes SchindelinOct 29, 2017
  14. Johannes SchindelinOct 28, 2017
  15. Stefan BellerOct 29, 2017
  16. Johannes SchindelinOct 28, 2017
  17. 0/7 git-describe <blob>Stefan Beller, Oct 31, 2017
  18. 1/7 list-objects.c: factor out traverse_trees_and_blobsStefan Beller, Oct 31, 2017
  19. Junio C HamanoOct 31, 2017
  20. 5/7 builtin/describe.c: factor out describe_commitStefan Beller, Oct 31, 2017
  21. 4/7 builtin/describe.c: print debug statements earlierStefan Beller, Oct 31, 2017
  22. Junio C HamanoOct 31, 2017
  23. Stefan BellerOct 31, 2017
  24. 6/7 builtin/describe.c: describe a blobStefan Beller, Oct 31, 2017
  25. Junio C HamanoOct 31, 2017
  26. Stefan BellerOct 31, 2017
  27. Junio C HamanoNov 1, 2017
  28. Stefan BellerNov 1, 2017
  29. Junio C HamanoNov 2, 2017
  30. Junio C HamanoNov 2, 2017
  31. Philip OakleyNov 4, 2017
  32. Junio C HamanoNov 5, 2017
  33. Philip OakleyNov 6, 2017
  34. Stefan BellerNov 9, 2017
  35. Philip OakleyNov 10, 2017
  36. Junio C HamanoNov 10, 2017
  37. 0/1 describe a blob: with better docsStefan Beller, Nov 10, 2017
  38. builtin/describe.c: describe a blobStefan Beller, Nov 10, 2017
  39. Junio C HamanoNov 13, 2017
  40. Stefan BellerNov 14, 2017
  41. Philip OakleyNov 20, 2017
  42. Philip OakleyNov 20, 2017
  43. Junio C HamanoNov 1, 2017
  44. 7/7 t6120: fix typo in test nameStefan Beller, Oct 31, 2017
  45. Junio C HamanoNov 1, 2017
  46. Stefan BellerNov 1, 2017
  47. Junio C HamanoNov 2, 2017
  48. 3/7 builtin/describe.c: rename `oid` to avoid variable shadowingStefan Beller, Oct 31, 2017
  49. Jacob KellerOct 31, 2017
  50. 2/7 revision.h: introduce blob/tree walking in order of the commitsStefan Beller, Oct 31, 2017
  51. Junio C HamanoOct 31, 2017
  52. Stefan BellerOct 31, 2017
  53. 0/7 git describe blobStefan Beller, Oct 31, 2017
  54. 1/7 list-objects.c: factor out traverse_trees_and_blobsStefan Beller, Oct 31, 2017
  55. Junio C HamanoNov 1, 2017
  56. 4/7 builtin/describe.c: print debug statements earlierStefan Beller, Oct 31, 2017
  57. Eric SunshineOct 31, 2017
  58. 7/7 t6120: fix typo in test nameStefan Beller, Oct 31, 2017
  59. 2/7 revision.h: introduce blob/tree walking in order of the commitsStefan Beller, Oct 31, 2017
  60. Junio C HamanoNov 1, 2017
  61. Johannes SchindelinNov 1, 2017
  62. Junio C HamanoNov 1, 2017
  63. Stefan BellerNov 1, 2017
  64. Johannes SchindelinNov 1, 2017
  65. Stefan BellerNov 1, 2017
  66. Johannes SchindelinNov 1, 2017
  67. Stefan BellerNov 1, 2017
  68. Johannes SchindelinNov 1, 2017
  69. Jeff KingNov 1, 2017
  70. Johannes SchindelinNov 1, 2017
  71. Junio C HamanoNov 2, 2017
  72. 6/7 builtin/describe.c: describe a blobStefan Beller, Oct 31, 2017
  73. Eric SunshineOct 31, 2017
  74. Stefan BellerNov 1, 2017
  75. Junio C HamanoNov 1, 2017
  76. Johannes SchindelinNov 1, 2017
  77. Stefan BellerNov 1, 2017
  78. Jacob KellerNov 1, 2017
  79. Johannes SchindelinNov 1, 2017
  80. Stefan BellerNov 1, 2017
  81. Johannes SchindelinNov 1, 2017
  82. Stefan BellerNov 1, 2017
  83. Jacob KellerNov 2, 2017
  84. Junio C HamanoNov 3, 2017
  85. Jacob KellerNov 3, 2017
  86. Junio C HamanoNov 3, 2017
  87. Andreas SchwabNov 2, 2017
  88. Stefan BellerNov 2, 2017
  89. Johannes SchindelinNov 3, 2017
  90. Stefan BellerNov 1, 2017
  91. 3/7 builtin/describe.c: rename `oid` to avoid variable shadowingStefan Beller, Oct 31, 2017
  92. 5/7 builtin/describe.c: factor out describe_commitStefan Beller, Oct 31, 2017
  93. Junio C HamanoNov 1, 2017
  94. 0/7 git describe blobStefan Beller, Nov 2, 2017
  95. 1/7 t6120: fix typo in test nameStefan Beller, Nov 2, 2017
  96. 2/7 list-objects.c: factor out traverse_trees_and_blobsStefan Beller, Nov 2, 2017
  97. 3/7 revision.h: introduce blob/tree walking in order of the commitsStefan Beller, Nov 2, 2017
  98. Jonathan TanNov 14, 2017
  99. 6/7 builtin/describe.c: factor out describe_commitStefan Beller, Nov 2, 2017
  100. 5/7 builtin/describe.c: print debug statements earlierStefan Beller, Nov 2, 2017
  101. Jonathan TanNov 14, 2017
  102. Stefan BellerNov 14, 2017
  103. 7/7 builtin/describe.c: describe a blobStefan Beller, Nov 2, 2017
  104. Jonathan TanNov 14, 2017
  105. Stefan BellerNov 14, 2017
  106. Jonathan TanNov 14, 2017
  107. 4/7 builtin/describe.c: rename `oid` to avoid variable shadowingStefan Beller, Nov 2, 2017
  108. Jacob KellerNov 3, 2017
  109. Junio C HamanoNov 3, 2017
  110. Stefan BellerNov 3, 2017

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.