Skip to content

Commit e23fd15

Browse files
devzero2000gitster
authored andcommitted
builtin/commit.c: reduce scope of variables
Signed-off-by: Elia Pinto <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e666b89 commit e23fd15

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

builtin/commit.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
307307
int fd;
308308
struct string_list partial;
309309
struct pathspec pathspec;
310-
char *old_index_env = NULL;
311310
int refresh_flags = REFRESH_QUIET;
312311

313312
if (is_status)
@@ -320,6 +319,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
320319
die(_("index file corrupt"));
321320

322321
if (interactive) {
322+
char *old_index_env = NULL;
323323
fd = hold_locked_index(&index_lock, 1);
324324

325325
refresh_cache_or_die(refresh_flags);
@@ -600,12 +600,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
600600
{
601601
struct stat statbuf;
602602
struct strbuf committer_ident = STRBUF_INIT;
603-
int commitable, saved_color_setting;
603+
int commitable;
604604
struct strbuf sb = STRBUF_INIT;
605-
char *buffer;
606605
const char *hook_arg1 = NULL;
607606
const char *hook_arg2 = NULL;
608-
int ident_shown = 0;
609607
int clean_message_contents = (cleanup_mode != CLEANUP_NONE);
610608
int old_display_comment_prefix;
611609

@@ -649,6 +647,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
649647
logfile);
650648
hook_arg1 = "message";
651649
} else if (use_message) {
650+
char *buffer;
652651
buffer = strstr(use_message_buffer, "\n\n");
653652
if (!use_editor && (!buffer || buffer[2] == '\0'))
654653
die(_("commit has empty message"));
@@ -753,6 +752,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
753752
/* This checks if committer ident is explicitly given */
754753
strbuf_addstr(&committer_ident, git_committer_info(IDENT_STRICT));
755754
if (use_editor && include_status) {
755+
int ident_shown = 0;
756+
int saved_color_setting;
756757
char *ai_tmp, *ci_tmp;
757758
if (whence != FROM_COMMIT)
758759
status_printf_ln(s, GIT_COLOR_NORMAL,
@@ -1510,7 +1511,6 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
15101511
struct ref_lock *ref_lock;
15111512
struct commit_list *parents = NULL, **pptr = &parents;
15121513
struct stat statbuf;
1513-
int allow_fast_forward = 1;
15141514
struct commit *current_head = NULL;
15151515
struct commit_extra_header *extra = NULL;
15161516

@@ -1558,6 +1558,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
15581558
} else if (whence == FROM_MERGE) {
15591559
struct strbuf m = STRBUF_INIT;
15601560
FILE *fp;
1561+
int allow_fast_forward = 1;
15611562

15621563
if (!reflog_msg)
15631564
reflog_msg = "commit (merge)";

0 commit comments

Comments
 (0)