Skip to content

Commit

Permalink
Make prune also run prune-packed
Browse files Browse the repository at this point in the history
Both the git-prune manpage and everday.txt say that git-prune should also prune
unpacked objects that are also found in packs, by running git prune-packed.

Junio thought this was "a regression when prune was rewritten as a built-in."

So modify prune to call prune-packed again.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
  • Loading branch information
J. Bruce Fields authored and Junio C Hamano committed Oct 22, 2006
1 parent 474a90f commit 2eb53e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
11 changes: 5 additions & 6 deletions builtin-prune-packed.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
static const char prune_packed_usage[] =
"git-prune-packed [-n]";

static int dryrun;

static void prune_dir(int i, DIR *dir, char *pathname, int len)
static void prune_dir(int i, DIR *dir, char *pathname, int len, int dryrun)
{
struct dirent *de;
char hex[40];
Expand All @@ -31,7 +29,7 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len)
rmdir(pathname);
}

static void prune_packed_objects(void)
void prune_packed_objects(int dryrun)
{
int i;
static char pathname[PATH_MAX];
Expand All @@ -50,14 +48,15 @@ static void prune_packed_objects(void)
d = opendir(pathname);
if (!d)
continue;
prune_dir(i, d, pathname, len + 3);
prune_dir(i, d, pathname, len + 3, dryrun);
closedir(d);
}
}

int cmd_prune_packed(int argc, const char **argv, const char *prefix)
{
int i;
int dryrun;

for (i = 1; i < argc; i++) {
const char *arg = argv[i];
Expand All @@ -73,6 +72,6 @@ int cmd_prune_packed(int argc, const char **argv, const char *prefix)
usage(prune_packed_usage);
}
sync();
prune_packed_objects();
prune_packed_objects(dryrun);
return 0;
}
2 changes: 2 additions & 0 deletions builtin-prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)

prune_object_dir(get_object_directory());

sync();
prune_packed_objects(show_only);
return 0;
}
1 change: 1 addition & 0 deletions builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extern int mailinfo(FILE *in, FILE *out, int ks, const char *encoding, const cha
extern int split_mbox(const char **mbox, const char *dir, int allow_bare, int nr_prec, int skip);
extern void stripspace(FILE *in, FILE *out);
extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix);
extern void prune_packed_objects(int);

extern int cmd_add(int argc, const char **argv, const char *prefix);
extern int cmd_apply(int argc, const char **argv, const char *prefix);
Expand Down

0 comments on commit 2eb53e6

Please sign in to comment.