From 4824d1b8c2d0e9e6a549c836aa6a7698fdba021b Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Wed, 29 Jan 2014 05:25:00 -0800 Subject: bisect.c: reduce scope of variable Signed-off-by: Elia Pinto Signed-off-by: Junio C Hamano --- bisect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bisect.c b/bisect.c index 1e46a4f50e..c718249a82 100644 --- a/bisect.c +++ b/bisect.c @@ -685,7 +685,6 @@ static void mark_expected_rev(char *bisect_rev_hex) static int bisect_checkout(char *bisect_rev_hex, int no_checkout) { - int res; mark_expected_rev(bisect_rev_hex); @@ -696,6 +695,7 @@ static int bisect_checkout(char *bisect_rev_hex, int no_checkout) die("update-ref --no-deref HEAD failed on %s", bisect_rev_hex); } else { + int res; res = run_command_v_opt(argv_checkout, RUN_GIT_CMD); if (res) exit(res); -- cgit v1.2.1 From e36f3a8a6fa1a1d99fb5730cd7642ecd0854b564 Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Wed, 29 Jan 2014 05:30:27 -0800 Subject: builtin/apply.c: reduce scope of variables Signed-off-by: Elia Pinto Signed-off-by: Junio C Hamano --- builtin/apply.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/builtin/apply.c b/builtin/apply.c index ef32e4f624..154c63fcbb 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -1943,13 +1943,7 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch) size - offset - hdrsize, patch); if (!patchsize) { - static const char *binhdr[] = { - "Binary files ", - "Files ", - NULL, - }; static const char git_binary[] = "GIT binary patch\n"; - int i; int hd = hdrsize + offset; unsigned long llen = linelen(buffer + hd, size - hd); @@ -1965,6 +1959,12 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch) patchsize = 0; } else if (!memcmp(" differ\n", buffer + hd + llen - 8, 8)) { + static const char *binhdr[] = { + "Binary files ", + "Files ", + NULL, + }; + int i; for (i = 0; binhdr[i]; i++) { int len = strlen(binhdr[i]); if (len < size - hd && -- cgit v1.2.1 From ac39b27786856c3d622d3ad2c1423ce1606ec7d4 Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Wed, 29 Jan 2014 05:33:15 -0800 Subject: builtin/blame.c: reduce scope of variables Signed-off-by: Elia Pinto Signed-off-by: Junio C Hamano --- builtin/blame.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/blame.c b/builtin/blame.c index 1407ae7eb2..862c0a23d1 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -1581,14 +1581,14 @@ static const char *format_time(unsigned long time, const char *tz_str, int show_raw_time) { static char time_buf[128]; - const char *time_str; - int time_len; - int tz; if (show_raw_time) { snprintf(time_buf, sizeof(time_buf), "%lu %s", time, tz_str); } else { + const char *time_str; + int time_len; + int tz; tz = atoi(tz_str); time_str = show_date(time, tz, blame_date_mode); time_len = strlen(time_str); -- cgit v1.2.1 From e666b89d76c9a25ce4cb3b73932a78524475fc27 Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Wed, 29 Jan 2014 05:36:15 -0800 Subject: builtin/clean.c: reduce scope of variable Signed-off-by: Elia Pinto Signed-off-by: Junio C Hamano --- builtin/clean.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/clean.c b/builtin/clean.c index 615cd57caf..22ad058c79 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -154,7 +154,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag, DIR *dir; struct strbuf quoted = STRBUF_INIT; struct dirent *e; - int res = 0, ret = 0, gone = 1, original_len = path->len, len, i; + int res = 0, ret = 0, gone = 1, original_len = path->len, len; unsigned char submodule_head[20]; struct string_list dels = STRING_LIST_INIT_DUP; @@ -242,6 +242,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag, } if (!*dir_gone && !quiet) { + int i; for (i = 0; i < dels.nr; i++) printf(dry_run ? _(msg_would_remove) : _(msg_remove), dels.items[i].string); } -- cgit v1.2.1 From e23fd15adab11eef216fd49a6329f381ce14061f Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Thu, 30 Jan 2014 07:15:56 -0800 Subject: builtin/commit.c: reduce scope of variables Signed-off-by: Elia Pinto Signed-off-by: Junio C Hamano --- builtin/commit.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 6ab4605cf5..42b32d710e 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)"; -- cgit v1.2.1 From bf7e645c90e08f0d3391502c888453033e446372 Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Wed, 29 Jan 2014 08:54:16 -0800 Subject: builtin/fetch.c: reduce scope of variable Signed-off-by: Elia Pinto Signed-off-by: Junio C Hamano --- builtin/fetch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index bd7a10164f..256c9eb020 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -987,7 +987,6 @@ static int fetch_multiple(struct string_list *list) static int fetch_one(struct remote *remote, int argc, const char **argv) { - int i; static const char **refs = NULL; struct refspec *refspec; int ref_nr = 0; @@ -1011,6 +1010,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv) if (argc > 0) { int j = 0; + int i; refs = xcalloc(argc + 1, sizeof(const char *)); for (i = 0; i < argc; i++) { if (!strcmp(argv[i], "tag")) { -- cgit v1.2.1 From 4f1c0b21e9045ff12e1880b5724a032031716a24 Mon Sep 17 00:00:00 2001 From: Elia Pinto Date: Wed, 29 Jan 2014 08:59:37 -0800 Subject: builtin/gc.c: reduce scope of variables Signed-off-by: Elia Pinto Signed-off-by: Junio C Hamano --- builtin/gc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/gc.c b/builtin/gc.c index 25f2237c08..5369012d93 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -187,13 +187,12 @@ static int need_to_gc(void) static const char *lock_repo_for_gc(int force, pid_t* ret_pid) { static struct lock_file lock; - static char locking_host[128]; char my_host[128]; struct strbuf sb = STRBUF_INIT; struct stat st; uintmax_t pid; FILE *fp; - int fd, should_exit; + int fd; if (pidfile) /* already locked */ @@ -205,6 +204,8 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid) fd = hold_lock_file_for_update(&lock, git_path("gc.pid"), LOCK_DIE_ON_ERROR); if (!force) { + static char locking_host[128]; + int should_exit; fp = fopen(git_path("gc.pid"), "r"); memset(locking_host, 0, sizeof(locking_host)); should_exit = -- cgit v1.2.1