diff options
| author | Usman Akinyemi <usmanakinyemi202@gmail.com> | 2025-02-15 21:20:50 +0530 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-02-18 09:05:12 -0800 |
| commit | 6aa09fd8726b7e8de37c0187a83c2c0fca280358 (patch) | |
| tree | 5c18acb38a28d07c24ac43c348ddd53f27722636 | |
| parent | version: refactor get_uname_info() (diff) | |
| download | git-6aa09fd8726b7e8de37c0187a83c2c0fca280358.tar.gz git-6aa09fd8726b7e8de37c0187a83c2c0fca280358.zip | |
version: extend get_uname_info() to hide system details
Currently, get_uname_info() function provides the full OS information.
In a following commit, we will need it to provide only the OS name.
Let's extend it to accept a "full" flag that makes it switch between
providing full OS information and providing only the OS name.
We may need to refactor this function in the future if an
`osVersion.format` is added.
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | builtin/bugreport.c | 2 | ||||
| -rw-r--r-- | version.c | 16 | ||||
| -rw-r--r-- | version.h | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/builtin/bugreport.c b/builtin/bugreport.c index 5e13d532a8..e3288a86c8 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -24,7 +24,7 @@ static void get_system_info(struct strbuf *sys_info) /* system call for other version info */ strbuf_addstr(sys_info, "uname: "); - get_uname_info(sys_info); + get_uname_info(sys_info, 1); strbuf_addstr(sys_info, _("compiler info: ")); get_compiler_info(sys_info); @@ -49,7 +49,7 @@ const char *git_user_agent_sanitized(void) return agent; } -int get_uname_info(struct strbuf *buf) +int get_uname_info(struct strbuf *buf, unsigned int full) { struct utsname uname_info; @@ -59,11 +59,13 @@ int get_uname_info(struct strbuf *buf) errno); return -1; } - - strbuf_addf(buf, "%s %s %s %s\n", - uname_info.sysname, - uname_info.release, - uname_info.version, - uname_info.machine); + if (full) + strbuf_addf(buf, "%s %s %s %s\n", + uname_info.sysname, + uname_info.release, + uname_info.version, + uname_info.machine); + else + strbuf_addf(buf, "%s\n", uname_info.sysname); return 0; } @@ -12,6 +12,6 @@ const char *git_user_agent_sanitized(void); Return -1 and put an error message into 'buf' in case of uname() error. Return 0 and put uname info into 'buf' otherwise. */ -int get_uname_info(struct strbuf *buf); +int get_uname_info(struct strbuf *buf, unsigned int full); #endif /* VERSION_H */ |
