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

[PATCH] submodule.h: use a named enum for RECURSE_SUBMODULES_*

From
Philippe Blain via GitGitGadget <gitgitgadget@gmail.com>
Date
Jan 5, 2022, 19:26 UTC
Message-ID
<pull.1111.git.1641410782015.gitgitgadget@gmail.com>
From: Philippe Blain <levraiphilippeblain@gmail.com>

Using a named enum allows casting an integer to the enum type in both GDB and LLDB:

    (gdb) p (enum diff_submodule_format) options->submodule_format
    $1 = DIFF_SUBMODULE_LOG
    (lldb) p (diff_submodule_format) options->submodule_format
    (diff_submodule_format) $1 = DIFF_SUBMODULE_LOG

In LLDB, it's also required to cast in the reversed direction, i.e. cast an enum constant into its corresponding integer:

    (lldb) p (int) diff_submodule_format::DIFF_SUBMODULE_SHORT
    (int) $0 = 0

Name the enum listing the different RECURSE_SUBMODULES_* modes, to make debugging easier.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
    submodule.h: use a named enum for RECURSE_SUBMODULES_*
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1111%2Fphil-blain%2Fsubmodule-recurse-enum-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1111/phil-blain/submodule-recurse-enum-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1111
 submodule.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/submodule.h b/submodule.h
index 6bd2c99fd99..55cf6f01d0c 100644
--- a/submodule.h
+++ b/submodule.h
@@ -13,7 +13,7 @@ struct repository;
 struct string_list;
 struct strbuf;
 
-enum {
+enum submodule_recurse_mode {
 	RECURSE_SUBMODULES_ONLY = -5,
 	RECURSE_SUBMODULES_CHECK = -4,
 	RECURSE_SUBMODULES_ERROR = -3,

base-commit: 2ae0a9cb8298185a94e5998086f380a355dd8907
-- 
gitgitgadget
Next: Junio C Hamano
Message 1 of 7 in “submodule.h: use a named enum for RECURSE_SUBMODULES_*”
  1. submodule.h: use a named enum for RECURSE_SUBMODULES_*Philippe Blain via GitGitGadget, Jan 5, 2022
  2. Junio C HamanoJan 5, 2022
  3. Philippe BlainJan 7, 2022
  4. Glen ChooJan 7, 2022
  5. Glen ChooJan 18, 2022
  6. submodule.h: use a named enum for RECURSE_SUBMODULES_*Philippe Blain via GitGitGadget, Apr 4, 2022
  7. Glen ChooApr 4, 2022

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.