From b5bd28adae5909b5b7e0159e0f2dde268ddf7907 Mon Sep 17 00:00:00 2001 From: Mathnerd314 Date: Mon, 23 May 2016 12:44:36 -0600 Subject: [PATCH] commit: Add --editor / -e command line argument Previously, the behavior was to run the editor if no subject or body was specified. This led to using commit -s '' in scripts, to avoid running the editor. In practice, manually editing commit messages is rare, whereas automated scripting is common, so instead default to not running the editor and only run it when -e is given. Closes: #305 Approved by: cgwalters --- src/ostree/ot-builtin-commit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c index a021fbfa..5acd0243 100644 --- a/src/ostree/ot-builtin-commit.c +++ b/src/ostree/ot-builtin-commit.c @@ -32,6 +32,7 @@ static char *opt_subject; static char *opt_body; +static gboolean opt_editor; static char *opt_parent; static gboolean opt_orphan; static char *opt_branch; @@ -73,6 +74,7 @@ static GOptionEntry options[] = { { "parent", 0, 0, G_OPTION_ARG_STRING, &opt_parent, "Parent ref, or \"none\"", "REF" }, { "subject", 's', 0, G_OPTION_ARG_STRING, &opt_subject, "One line subject", "SUBJECT" }, { "body", 'm', 0, G_OPTION_ARG_STRING, &opt_body, "Full description", "BODY" }, + { "editor", 'e', 0, G_OPTION_ARG_NONE, &opt_editor, "Use an editor to write the commit message", NULL }, { "branch", 'b', 0, G_OPTION_ARG_STRING, &opt_branch, "Branch", "BRANCH" }, { "orphan", 0, 0, G_OPTION_ARG_NONE, &opt_orphan, "Create a commit without writing a ref", NULL }, { "tree", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_trees, "Overlay the given argument as a tree", "dir=PATH or tar=TARFILE or ref=COMMIT" }, @@ -425,7 +427,7 @@ ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError goto out; } - if (!opt_subject && !opt_body) + if (opt_editor) { if (!commit_editor (repo, opt_branch, &opt_subject, &opt_body, cancellable, error)) goto out;