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

[PATCH 1/3] checkout: describe_detached_head: remove 3dots after committish

From
Ann T Ropea <bedhanger@gmx.de>
Date
Nov 5, 2017, 16:27 UTC
Message-ID
<20171105162730.31405-1-bedhanger@gmx.de>

When a committish, C, is immediately followed by 3dots (...) which are, in turn, not followed by another committish, we are usually asking for the revision range C...HEAD, which is known as the symmetric difference of C and HEAD.

When describe_detached_head is invoked, it prints the committish followed by 3dots as elaborated above when it indicates the current and previous HEAD positions. For example:

   # Randomly check out one of the first seven git.git commits
   # (Starting with a detached HEAD already)
   $ git checkout $(git rev-list master | tail -7 | shuf | head -1)
   Previous HEAD position was bfcf2d7874f7... checkout: describe_detached_head: remove 3dots after committish
   HEAD is now at 19b2860cba57... Use "-Wall -O2" for the compiler to get more warnings.

"Evaluating" this displayed pseudo-range for the current HEAD indication resolves to the empty range (C...HEAD, where C equals HEAD).

For the previous HEAD indication, the results of the "evaluation" are somewhat more difficult to predict: previous here refers to what the reflog dictates (this is not necessarily the topological ancestor in the DAG, i.e., HEAD^). In the example above, the "range" resolves to almost all commits in the author's clone of git.git. Running the command again causes the then previous to current HEAD position "range" to be a lot smaller.

This could be confusing not only for novices; in either case, no range should be insinuated by describe_detached_head.

Granted, this "evaluation" is at the moment, if at all, only performed in the mind of the observer. And, to be sure, the 3dots *are* intended as a continuation indication for the abbreviated SHA-1 value. Nevertheless, we should get rid of them, for the following reasons:

   * they would still be displayed if someone had their core.abbrev
     config value set to the max
   * when the built-in version of checkout was introduced by commit
        782c2d65c240 ("Build in checkout", 2008-02-07)
     no 3dots were present in the legacy git-checkout.sh (see
     contrib/examples/git-checkout.sh)
   * when git-reset causes a new HEAD line to be printed (during a hard
     reset), neither builtin/reset.c nor contrib/examples/git-reset.sh
     mention 3dots

Lest we confuse the meticulous observer, we ought to retire the 3dots in the circumstances described above.

Signed-off-by: Ann T Ropea <bedhanger@gmx.de>
---
 builtin/checkout.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index fc4f8fd2ea29..59cc52e55855 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -404,7 +404,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)
 	struct strbuf sb = STRBUF_INIT;
 	if (!parse_commit(commit))
 		pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
-	fprintf(stderr, "%s %s... %s\n", msg,
+	fprintf(stderr, "%s %s %s\n", msg,
 		find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
 	strbuf_release(&sb);
 }
-- 
2.13.6
Next: Ann T Ropea
Message 1 of 58 in “checkout: describe_detached_head: remove 3dots after committish”
  1. 1/3 checkout: describe_detached_head: remove 3dots after committishAnn T Ropea, Nov 5, 2017
  2. 2/3 Documentation: user-manual: limit potentially confusing usage of 3dots (and 2dots)Ann T Ropea, Nov 5, 2017
  3. 3/3 Documentation: revisions: add note about 3dots usages as continuation indicationsAnn T Ropea, Nov 5, 2017
  4. Junio C HamanoNov 6, 2017
  5. Junio C HamanoNov 6, 2017
  6. Philip OakleyNov 7, 2017
  7. Junio C HamanoNov 7, 2017
  8. Ann T RopeaNov 7, 2017
  9. Philip OakleyNov 7, 2017
  10. Junio C HamanoNov 8, 2017
  11. Philip OakleyNov 9, 2017
  12. Ann T RopeaNov 13, 2017
  13. Ann T RopeaNov 13, 2017
  14. Ann T RopeaNov 13, 2017
  15. Junio C HamanoNov 14, 2017
  16. Ann T RopeaNov 19, 2017
  17. Junio C HamanoNov 20, 2017
  18. Ann T RopeaNov 19, 2017
  19. Ann T RopeaNov 19, 2017
  20. Eric SunshineNov 19, 2017
  21. Ann T RopeaNov 19, 2017
  22. Eric SunshineNov 19, 2017
  23. Ann T RopeaNov 19, 2017
  24. Junio C HamanoNov 20, 2017
  25. Philip OakleyNov 20, 2017
  26. Junio C HamanoNov 22, 2017
  27. Philip OakleyNov 22, 2017
  28. Junio C HamanoNov 24, 2017
  29. Ann T RopeaNov 24, 2017
  30. Ann T RopeaNov 24, 2017
  31. Ann T RopeaNov 24, 2017
  32. Ann T RopeaNov 24, 2017
  33. Ann T RopeaNov 24, 2017
  34. Ann T RopeaNov 24, 2017
  35. Junio C HamanoNov 25, 2017
  36. Junio C HamanoNov 26, 2017
  37. Junio C HamanoNov 26, 2017
  38. Junio C HamanoNov 26, 2017
  39. Ann T RopeaDec 3, 2017
  40. Ann T RopeaDec 3, 2017
  41. Ann T RopeaDec 3, 2017
  42. Ann T RopeaDec 3, 2017
  43. Ann T RopeaDec 3, 2017
  44. Junio C HamanoDec 4, 2017
  45. Ann T RopeaDec 4, 2017
  46. Junio C HamanoDec 5, 2017
  47. Ann T RopeaDec 6, 2017
  48. Junio C HamanoDec 6, 2017
  49. Ann T RopeaDec 6, 2017
  50. Ann T RopeaDec 3, 2017
  51. Ann T RopeaDec 3, 2017
  52. Junio C HamanoDec 4, 2017
  53. Ann T RopeaNov 19, 2017
  54. Junio C HamanoNov 20, 2017
  55. Ann T RopeaNov 13, 2017
  56. Ann T RopeaNov 13, 2017
  57. Ann T RopeaNov 13, 2017
  58. Junio C HamanoNov 14, 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.