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

[PATCH v3 1/2] revision: differentiate if --no-abbrev asked explicitly

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
Aug 14, 2020, 00:23 UTC
Message-ID
<9a26c5b6110081cd8d029f2ab0327c4a1d228ef7.1597364493.git.congdanhqx@gmail.com>
In-Reply-To
<cover.1597364493.git.congdanhqx@gmail.com>

When we see --no-abbrev in command's arguments, we reset the 'abbrev' field in diff-options to 0 and this value will be looked at diff_abbrev_oid() to decide not to truncate the object name.

In a later change, we want to extend --abbrev support to diff-patch format. When --abbrev supporting diff-patch, we need to differentiate those below scenarios:

* None of those options --abbrev, --no-abbrev, and --full-index are
  asked. diff-patch should keep old behavior of using DEFAULT_ABBREV
  for the index length.
* --no-abbrev is asked, diff-patch should treat this option as same as
  --full-index and show full object name in index line.

While not doing anything is very effective way to show full object id, we couldn't differentiate if --no-abbrev or not.

We can differentiate those above scenarios by either:
* Add a new field in diff-options to mark if --no-abbrev was asked.
  With this option, we have a new field for a single purpose, and one
  more thing to worry about.
* Treat --no-abbrev as same as --full-index. This option is problematic,
  since we want to allow --abbrev overwrite --no-abbrev again.
  On the other hand, we also need to keep our promises with scripter
  who uses --full-index to ask for full object names in index line,
  so, we need to respsect --full-index regardless of --abbrev.
* Set 'abbrev' field in diff-options to the length of the hash we are
  using. With this option, we can differentiate if --no-abbrev was asked
  ('abbrev' is hash's length) or none of --[no-]abbrev was asked
  ('abbrev' is '0'), script with --full-index still works and our
  headache is kept as is.
Let's ask for full object id if we see --no-abbrev.
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 revision.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/revision.c b/revision.c
index 3dcf689341..24027b1af3 100644
--- a/revision.c
+++ b/revision.c
@@ -2430,7 +2430,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 	} else if (!strcmp(arg, "--always")) {
 		revs->always_show_header = 1;
 	} else if (!strcmp(arg, "--no-abbrev")) {
-		revs->abbrev = 0;
+		revs->abbrev = hexsz;
 	} else if (!strcmp(arg, "--abbrev")) {
 		revs->abbrev = DEFAULT_ABBREV;
 	} else if (skip_prefix(arg, "--abbrev=", &optarg)) {
-- 
2.28.0.215.g32ffa52ee0
Previous: Đoàn Trần Công DanhNext: Junio C Hamano
Message 18 of 41 in “extend --abbrev support to diff-patch format”
  1. 0/2 extend --abbrev support to diff-patch formatĐoàn Trần Công Danh, Aug 9, 2020
  2. 1/2 revision: differentiate if --no-abbrev asked explicitlyĐoàn Trần Công Danh, Aug 9, 2020
  3. 2/2 diff: extend --abbrev support to diff-patch formatĐoàn Trần Công Danh, Aug 9, 2020
  4. Junio C HamanoAug 9, 2020
  5. Jeff KingAug 10, 2020
  6. Đoàn Trần Công DanhAug 10, 2020
  7. Junio C HamanoAug 10, 2020
  8. Jeff KingAug 10, 2020
  9. Đoàn Trần Công DanhAug 11, 2020
  10. Jeff KingAug 11, 2020
  11. Đoàn Trần Công DanhAug 11, 2020
  12. Junio C HamanoAug 10, 2020
  13. 0/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 11, 2020
  14. 1/2 revision: differentiate if --no-abbrev asked explicitlyĐoàn Trần Công Danh, Aug 11, 2020
  15. Junio C HamanoAug 11, 2020
  16. 2/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 11, 2020
  17. 0/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 14, 2020
  18. 1/2 revision: differentiate if --no-abbrev asked explicitlyĐoàn Trần Công Danh, Aug 14, 2020
  19. Junio C HamanoAug 14, 2020
  20. Đoàn Trần Công DanhAug 14, 2020
  21. Junio C HamanoAug 14, 2020
  22. Đoàn Trần Công DanhAug 14, 2020
  23. Junio C HamanoAug 19, 2020
  24. 2/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 14, 2020
  25. SZEDER GáborAug 14, 2020
  26. Junio C HamanoAug 14, 2020
  27. Junio C HamanoAug 14, 2020
  28. brian m. carlsonAug 15, 2020
  29. Đoàn Trần Công DanhAug 15, 2020
  30. Junio C HamanoAug 17, 2020
  31. Junio C HamanoAug 20, 2020
  32. 0/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 20, 2020
  33. 2/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 20, 2020
  34. Junio C HamanoAug 20, 2020
  35. 1/2 t4013: improve diff-post-processor logicĐoàn Trần Công Danh, Aug 20, 2020
  36. Junio C HamanoAug 20, 2020
  37. Đoàn Trần Công DanhAug 21, 2020
  38. Junio C HamanoAug 21, 2020
  39. 0/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 21, 2020
  40. 2/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 21, 2020
  41. 1/2 t4013: improve diff-post-processor logicĐoàn Trần Công Danh, Aug 21, 2020

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.