git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 5/5] builtin/commit.c: reduce scope of variables
@ 2014-01-29 13:48 Elia Pinto
  2014-01-29 20:17 ` Eric Sunshine
  0 siblings, 1 reply; 3+ messages in thread
From: Elia Pinto @ 2014-01-29 13:48 UTC (permalink / raw
  To: git; +Cc: Elia Pinto

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
 builtin/commit.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 3767478..eea4421 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -307,7 +307,6 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
 	int fd;
 	struct string_list partial;
 	struct pathspec pathspec;
-	char *old_index_env = NULL;
 	int refresh_flags = REFRESH_QUIET;
 
 	if (is_status)
@@ -320,6 +319,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
 		die(_("index file corrupt"));
 
 	if (interactive) {
+		char *old_index_env = NULL;
 		fd = hold_locked_index(&index_lock, 1);
 
 		refresh_cache_or_die(refresh_flags);
@@ -600,12 +600,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 {
 	struct stat statbuf;
 	struct strbuf committer_ident = STRBUF_INIT;
-	int commitable, saved_color_setting;
+	int commitable;
 	struct strbuf sb = STRBUF_INIT;
-	char *buffer;
 	const char *hook_arg1 = NULL;
 	const char *hook_arg2 = NULL;
-	int ident_shown = 0;
 	int clean_message_contents = (cleanup_mode != CLEANUP_NONE);
 	int old_display_comment_prefix;
 
@@ -649,6 +647,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 				  logfile);
 		hook_arg1 = "message";
 	} else if (use_message) {
+		char *buffer;
 		buffer = strstr(use_message_buffer, "\n\n");
 		if (!use_editor && (!buffer || buffer[2] == '\0'))
 			die(_("commit has empty message"));
@@ -753,6 +752,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	/* This checks if committer ident is explicitly given */
 	strbuf_addstr(&committer_ident, git_committer_info(IDENT_STRICT));
 	if (use_editor && include_status) {
+		int ident_shown = 0;
+		int saved_color_setting;
 		char *ai_tmp, *ci_tmp;
 		if (whence != FROM_COMMIT)
 			status_printf_ln(s, GIT_COLOR_NORMAL,
@@ -1510,7 +1511,6 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	struct ref_lock *ref_lock;
 	struct commit_list *parents = NULL, **pptr = &parents;
 	struct stat statbuf;
-	int allow_fast_forward = 1;
 	struct commit *current_head = NULL;
 	struct commit_extra_header *extra = NULL;
 
@@ -1576,6 +1576,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		}
 		fclose(fp);
 		strbuf_release(&m);
+		int allow_fast_forward = 1;
 		if (!stat(git_path("MERGE_MODE"), &statbuf)) {
 			if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)
 				die_errno(_("could not read MERGE_MODE"));
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 5/5] builtin/commit.c: reduce scope of variables
  2014-01-29 13:48 [PATCH 5/5] builtin/commit.c: reduce scope of variables Elia Pinto
@ 2014-01-29 20:17 ` Eric Sunshine
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Sunshine @ 2014-01-29 20:17 UTC (permalink / raw
  To: Elia Pinto; +Cc: Git List

On Wed, Jan 29, 2014 at 8:48 AM, Elia Pinto <gitter.spiros@gmail.com> wrote:
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 3767478..eea4421 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1510,7 +1511,6 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>         struct ref_lock *ref_lock;
>         struct commit_list *parents = NULL, **pptr = &parents;
>         struct stat statbuf;
> -       int allow_fast_forward = 1;
>         struct commit *current_head = NULL;
>         struct commit_extra_header *extra = NULL;
>
> @@ -1576,6 +1576,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>                 }
>                 fclose(fp);
>                 strbuf_release(&m);
> +               int allow_fast_forward = 1;

This introduces a declaration-after-statement, which is frowned upon
in this project.

>                 if (!stat(git_path("MERGE_MODE"), &statbuf)) {
>                         if (strbuf_read_file(&sb, git_path("MERGE_MODE"), 0) < 0)
>                                 die_errno(_("could not read MERGE_MODE"));
> --
> 1.7.10.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 5/5] builtin/commit.c: reduce scope of variables
@ 2014-01-30 15:15 Elia Pinto
  0 siblings, 0 replies; 3+ messages in thread
From: Elia Pinto @ 2014-01-30 15:15 UTC (permalink / raw
  To: git; +Cc: Elia Pinto

Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
---
This a reroll of a previous patch. Corrected the declaration
after statement issue.


 builtin/commit.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 3767478..a684296 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -307,7 +307,6 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
 	int fd;
 	struct string_list partial;
 	struct pathspec pathspec;
-	char *old_index_env = NULL;
 	int refresh_flags = REFRESH_QUIET;
 
 	if (is_status)
@@ -320,6 +319,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
 		die(_("index file corrupt"));
 
 	if (interactive) {
+		char *old_index_env = NULL;
 		fd = hold_locked_index(&index_lock, 1);
 
 		refresh_cache_or_die(refresh_flags);
@@ -600,12 +600,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 {
 	struct stat statbuf;
 	struct strbuf committer_ident = STRBUF_INIT;
-	int commitable, saved_color_setting;
+	int commitable;
 	struct strbuf sb = STRBUF_INIT;
-	char *buffer;
 	const char *hook_arg1 = NULL;
 	const char *hook_arg2 = NULL;
-	int ident_shown = 0;
 	int clean_message_contents = (cleanup_mode != CLEANUP_NONE);
 	int old_display_comment_prefix;
 
@@ -649,6 +647,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 				  logfile);
 		hook_arg1 = "message";
 	} else if (use_message) {
+		char *buffer;
 		buffer = strstr(use_message_buffer, "\n\n");
 		if (!use_editor && (!buffer || buffer[2] == '\0'))
 			die(_("commit has empty message"));
@@ -753,6 +752,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 	/* This checks if committer ident is explicitly given */
 	strbuf_addstr(&committer_ident, git_committer_info(IDENT_STRICT));
 	if (use_editor && include_status) {
+		int ident_shown = 0;
+		int saved_color_setting;
 		char *ai_tmp, *ci_tmp;
 		if (whence != FROM_COMMIT)
 			status_printf_ln(s, GIT_COLOR_NORMAL,
@@ -1510,7 +1511,6 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	struct ref_lock *ref_lock;
 	struct commit_list *parents = NULL, **pptr = &parents;
 	struct stat statbuf;
-	int allow_fast_forward = 1;
 	struct commit *current_head = NULL;
 	struct commit_extra_header *extra = NULL;
 
@@ -1558,6 +1558,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	} else if (whence == FROM_MERGE) {
 		struct strbuf m = STRBUF_INIT;
 		FILE *fp;
+		int allow_fast_forward = 1;
 
 		if (!reflog_msg)
 			reflog_msg = "commit (merge)";
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-30 15:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-29 13:48 [PATCH 5/5] builtin/commit.c: reduce scope of variables Elia Pinto
2014-01-29 20:17 ` Eric Sunshine
  -- strict thread matches above, loose matches on Subject: below --
2014-01-30 15:15 Elia Pinto

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).