From: Benjamin Kramer <benny.kra@googlemail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 2/2] moved some variables into narrower scopes
Date: Sat, 7 Mar 2009 21:02:26 +0100 [thread overview]
Message-ID: <7f978c810903071202p18c4f8fjbddc0176b80c76b2@mail.gmail.com> (raw)
they weren't used outside and can be safely moved
builtin-fmt-merge-msg: moved variable to narrower scope
combine-diff: moved variable to narrower scope
log-tree: moved variable to narrower scope
upload-pack: moved variable to narrower scope
upload-pack: removed unused assignment
Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com>
---
builtin-fmt-merge-msg.c | 5 ++---
combine-diff.c | 3 +--
log-tree.c | 6 +++---
upload-pack.c | 5 ++---
4 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index df18f40..5c5b310 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -257,7 +257,7 @@ static void shortlog(const char *name, unsigned char *sha1,
int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
int limit = 20, i = 0, pos = 0;
char line[1024];
- char *p = line, *sep = "";
+ char *sep = "";
unsigned char head_sha1[20];
const char *current_branch;
@@ -271,9 +271,8 @@ int fmt_merge_msg(int merge_summary, struct strbuf
*in, struct strbuf *out) {
/* get a line */
while (pos < in->len) {
int len;
- char *newline;
+ char *newline, *p = in->buf + pos;
- p = in->buf + pos;
newline = strchr(p, '\n');
len = newline ? newline - p : strlen(p);
pos += len + !!newline;
diff --git a/combine-diff.c b/combine-diff.c
index bccc018..b3b86ae 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -526,7 +526,6 @@ static void dump_sline(struct sline *sline,
unsigned long cnt, int num_parent,
return; /* result deleted */
while (1) {
- struct sline *sl = &sline[lno];
unsigned long hunk_end;
unsigned long rlines;
const char *hunk_comment = NULL;
@@ -592,7 +591,7 @@ static void dump_sline(struct sline *sline,
unsigned long cnt, int num_parent,
struct lline *ll;
int j;
unsigned long p_mask;
- sl = &sline[lno++];
+ struct sline *sl = &sline[lno++];
ll = (sl->flag & no_pre_delete) ? NULL : sl->lost_head;
while (ll) {
fputs(c_old, stdout);
diff --git a/log-tree.c b/log-tree.c
index 84a74e5..63cff74 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -79,18 +79,18 @@ void show_decorations(struct rev_info *opt, struct
commit *commit)
*/
static int detect_any_signoff(char *letter, int size)
{
- char ch, *cp;
+ char *cp;
int seen_colon = 0;
int seen_at = 0;
int seen_name = 0;
int seen_head = 0;
cp = letter + size;
- while (letter <= --cp && (ch = *cp) == '\n')
+ while (letter <= --cp && *cp == '\n')
continue;
while (letter <= cp) {
- ch = *cp--;
+ char ch = *cp--;
if (ch == '\n')
break;
diff --git a/upload-pack.c b/upload-pack.c
index e15ebdc..a49d872 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -397,12 +397,11 @@ static int get_common_commits(void)
static char line[1000];
unsigned char sha1[20];
char hex[41], last_hex[41];
- int len;
save_commit_buffer = 0;
for(;;) {
- len = packet_read_line(0, line, sizeof(line));
+ int len = packet_read_line(0, line, sizeof(line));
reset_timeout();
if (!len) {
@@ -410,7 +409,7 @@ static int get_common_commits(void)
packet_write(1, "NAK\n");
continue;
}
- len = strip(line, len);
+ strip(line, len);
if (!prefixcmp(line, "have ")) {
switch (got_sha1(line+5, sha1)) {
case -1: /* they have what we do not */
--
1.6.2.81.ge603.dirty
reply other threads:[~2009-03-07 20:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7f978c810903071202p18c4f8fjbddc0176b80c76b2@mail.gmail.com \
--to=benny.kra@googlemail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).