Skip to content

Commit

Permalink
Move local variables to narrower scopes
Browse files Browse the repository at this point in the history
These weren't used outside and can be safely moved

Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
d0k authored and gitster committed Mar 8, 2009
1 parent eb3a9dd commit fd13b21
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
6 changes: 2 additions & 4 deletions builtin-fmt-merge-msg.c
Expand Up @@ -256,8 +256,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;

Expand All @@ -271,9 +270,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;
Expand Down
3 changes: 1 addition & 2 deletions combine-diff.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions log-tree.c
Expand Up @@ -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;

Expand Down
5 changes: 2 additions & 3 deletions upload-pack.c
Expand Up @@ -397,20 +397,19 @@ 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) {
if (have_obj.nr == 0 || multi_ack)
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 */
Expand Down

0 comments on commit fd13b21

Please sign in to comment.