@matheusbsbs / matheus-bagliano / commits / 4803466f62
Fork 0

builtin-commit: avoid double-negation in the code.

The flag no_edit meant "we have got final message from the user and will not editing it any further", but there were quite a few places that needed to check !no_edit. Rename the variable to use_editor and reverse the logic everywhere. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Dec 22, 2007 at 19:25 UTC 4803466f62777fe3d0b33c8f999ec392f47a5b09
1 file changed +6 -6
builtin-commit.c
+6 -6
@@ -48,7 +48,7 @@ static char *edit_message, *use_message;
48 static int all, edit_flag, also, interactive, only, amend, signoff;
49 static int quiet, verbose, untracked_files, no_verify, allow_empty;
50
51 -static int no_edit, initial_commit, in_merge;
51 +static int use_editor = 1, initial_commit, in_merge;
52 const char *only_include_assumed;
53 struct strbuf message;
54
@@ -372,7 +372,7 @@ static int prepare_log_message(const char *index_file, const char *prefix)
372
373 strbuf_release(&sb);
374
375 - if (no_edit) {
375 + if (!use_editor) {
376 struct rev_info rev;
377 unsigned char sha1[20];
378 const char *parent = "HEAD";
@@ -398,7 +398,7 @@ static int prepare_log_message(const char *index_file, const char *prefix)
398 return !!DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES);
399 }
400
401 - if (in_merge && !no_edit)
401 + if (in_merge)
402 fprintf(fp,
403 "#\n"
404 "# It looks like you may be committing a MERGE.\n"
@@ -513,9 +513,9 @@ static int parse_and_validate_options(int argc, const char *argv[],
513 argc = parse_options(argc, argv, builtin_commit_options, usage, 0);
514
515 if (logfile || message.len || use_message)
516 - no_edit = 1;
516 + use_editor = 0;
517 if (edit_flag)
518 - no_edit = 0;
518 + use_editor = 1;
519
520 if (get_sha1("HEAD", head_sha1))
521 initial_commit = 1;
@@ -796,7 +796,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
796
797 /* Get the commit message and validate it */
798 header_len = sb.len;
799 - if (!no_edit) {
799 + if (use_editor) {
800 char index[PATH_MAX];
801 const char *env[2] = { index, NULL };
802 snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);