Skip to content

Commit

Permalink
builtin/push.c: remove useless temporary variable
Browse files Browse the repository at this point in the history
Creating a variable nr here to use throughout the function only to change
refspec_nr to nr at the end, having not used refspec_nr the entire time,
is rather pointless. Instead, simply increment refspec_nr.

While at it, use ALLOC_GROW() instead of xrealloc().

Signed-off-by: Jared Hance <jaredhance@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jared Hance authored and Junio C Hamano committed Aug 2, 2010
1 parent 61bf126 commit 8a883b0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions builtin/push.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ static int progress;

static const char **refspec;
static int refspec_nr;
static int refspec_alloc;

static void add_refspec(const char *ref)
{
int nr = refspec_nr + 1;
refspec = xrealloc(refspec, nr * sizeof(char *));
refspec[nr-1] = ref;
refspec_nr = nr;
refspec_nr++;
ALLOC_GROW(refspec, refspec_nr, refspec_alloc);
refspec[refspec_nr-1] = ref;
}

static void set_refspecs(const char **refs, int nr)
Expand Down

0 comments on commit 8a883b0

Please sign in to comment.