Skip to content

Commit

Permalink
builtin-remote: refactor duplicated cleanup code
Browse files Browse the repository at this point in the history
This patch moves identical lines of code into a cleanup function. The
function has two callers and is about to gain a third.

Also removed a bogus NEEDSWORK comment per Daniel Barkalow:

  Actually, the comment is wrong; "remote" comes from remote_get(),
  which returns things from a cache in remote.c; there could be a
  remote_put() to let the code know that the caller is done with the
  object, but it wouldn't presently do anything.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jay Soffian authored and Junio C Hamano committed Feb 27, 2009
1 parent c6f5a7a commit 8873323
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions builtin-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,13 @@ static void show_list(const char *title, struct string_list *list,
printf(" %s\n", list->items[i].string);
}

static void free_remote_ref_states(struct ref_states *states)
{
string_list_clear(&states->new, 0);
string_list_clear(&states->stale, 0);
string_list_clear(&states->tracked, 0);
}

static int get_remote_ref_states(const char *name,
struct ref_states *states,
int query)
Expand Down Expand Up @@ -738,10 +745,7 @@ static int show(int argc, const char **argv)
}
}

/* NEEDSWORK: free remote */
string_list_clear(&states.new, 0);
string_list_clear(&states.stale, 0);
string_list_clear(&states.tracked, 0);
free_remote_ref_states(&states);
}

return result;
Expand Down Expand Up @@ -792,10 +796,7 @@ static int prune(int argc, const char **argv)
warn_dangling_symref(dangling_msg, refname);
}

/* NEEDSWORK: free remote */
string_list_clear(&states.new, 0);
string_list_clear(&states.stale, 0);
string_list_clear(&states.tracked, 0);
free_remote_ref_states(&states);
}

return result;
Expand Down

0 comments on commit 8873323

Please sign in to comment.