From b55232200440c86db55c7fc319d6ff0c5352bb1c Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 26 Jul 2021 17:00:36 +0200 Subject: [PATCH] Handle RAVC2_USER environment variable --- libr/main/ravc2.c | 8 +++++++- man/ravc2.1 | 17 ++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/libr/main/ravc2.c b/libr/main/ravc2.c index 4e44171891..d76e4f1fd9 100644 --- a/libr/main/ravc2.c +++ b/libr/main/ravc2.c @@ -10,6 +10,8 @@ static void ravc2_show_help(void) { " branch list all available branches\n" " commit [a] [m] [f] perform a commit with the added files\n" " branch [name] change to another branch\n" + "Environment:\n" + " RAVC2_USER=[name] Override cfg.user value to author commit.\n" "Examples:\n" " ravc2 init\n" " man ravc2\n"); @@ -103,7 +105,11 @@ R_API int r_main_ravc2(int argc, const char **argv) { return -10; } } - char *author = r_sys_whoami (); + char *author = r_sys_getenv ("RAVC2_USER"); + if (R_STR_ISEMPTY (author)) { + free (author); + author = r_sys_whoami (); + } if (!author) { free (message); r_list_free (files); diff --git a/man/ravc2.1 b/man/ravc2.1 index 58449064fa..3174109c8d 100644 --- a/man/ravc2.1 +++ b/man/ravc2.1 @@ -1,11 +1,11 @@ -.Dd Dec 28, 2020 +.Dd Jul 26, 2021 .Dt RAVC2 1 .Sh NAME .Nm ravc2 .Nd radare version control .Sh SYNOPSIS .Nm ravc2 -.Op Fl ebBsSvxkKh +.Op Fl hv .Op [expr] ... .Sh DESCRIPTION This command is part of the radare project. @@ -14,6 +14,7 @@ Implements a simple version control system that aims to work as frontend for git .Pp This command is pretty new and experimental. .Sh OPTIONS +.Bl -tag -width Fl .It Fl h Show usage help message .It Fl v @@ -22,12 +23,14 @@ Display version .Sh USAGE Available variable types are: .Pp -ravc2 init -echo hello world > README.md -ravc2 add README.md -ravc2 branch -ravc2 commit + ravc2 init + echo hello world > README.md + ravc2 add README.md + ravc2 branch + ravc2 commit .Pp +.Sh ENVIRONMENT + RAVC2_USER overrides cfg.user, which is based on r_sys_whoami() which is used to define the author for the VC commits. .Sh SEE ALSO .Pp .Xr radare2(1)