fputc('\n', rpt);
}
+static void dump_marks_helper(FILE *, uintmax_t, struct mark_set *);
+
static void write_crash_report(const char *err)
{
char *loc = git_path("fast_import_crash_%d", getpid());
write_branch_report(rpt, b);
}
+ if (first_tag) {
+ struct tag *tg;
+ fputc('\n', rpt);
+ fputs("Annotated Tags\n", rpt);
+ fputs("--------------\n", rpt);
+ for (tg = first_tag; tg; tg = tg->next_tag) {
+ fputs(sha1_to_hex(tg->sha1), rpt);
+ fputc(' ', rpt);
+ fputs(tg->name, rpt);
+ fputc('\n', rpt);
+ }
+ }
+
+ fputc('\n', rpt);
+ fputs("Marks\n", rpt);
+ fputs("-----\n", rpt);
+ if (mark_file)
+ fprintf(rpt, " exported to %s\n", mark_file);
+ else
+ dump_marks_helper(rpt, 0, marks);
+
fputc('\n', rpt);
fputs("-------------------\n", rpt);
fputs("END OF CRASH REPORT\n", rpt);
fclose(rpt);
}
+static void end_packfile(void);
+static void unkeep_all_packs(void);
+static void dump_marks(void);
+
static NORETURN void die_nicely(const char *err, va_list params)
{
static int zombie;
if (!zombie) {
zombie = 1;
write_crash_report(message);
+ end_packfile();
+ unkeep_all_packs();
+ dump_marks();
}
exit(128);
}
struct ref_lock *lock;
unsigned char old_sha1[20];
+ if (is_null_sha1(b->sha1))
+ return 0;
if (read_ref(b->name, old_sha1))
hashclr(old_sha1);
lock = lock_any_ref_for_update(b->name, old_sha1, 0);
ungetc(term_char, stdin);
}
-static void cmd_mark(void)
+static void parse_mark(void)
{
if (!prefixcmp(command_buf.buf, "mark :")) {
next_mark = strtoumax(command_buf.buf + 6, NULL, 10);
next_mark = 0;
}
-static void cmd_data(struct strbuf *sb)
+static void parse_data(struct strbuf *sb)
{
strbuf_reset(sb);
return ident;
}
-static void cmd_new_blob(void)
+static void parse_new_blob(void)
{
static struct strbuf buf = STRBUF_INIT;
read_next_command();
- cmd_mark();
- cmd_data(&buf);
+ parse_mark();
+ parse_data(&buf);
store_object(OBJ_BLOB, &buf, &last_blob, NULL, next_mark);
}
p = uq.buf;
}
read_next_command();
- cmd_data(&buf);
+ parse_data(&buf);
store_object(OBJ_BLOB, &buf, &last_blob, sha1, 0);
} else if (oe) {
if (oe->type != OBJ_BLOB)
load_tree(&b->branch_tree);
}
-static void cmd_from_commit(struct branch *b, char *buf, unsigned long size)
+static void parse_from_commit(struct branch *b, char *buf, unsigned long size)
{
if (!buf || size < 46)
die("Not a valid commit: %s", sha1_to_hex(b->sha1));
b->branch_tree.versions[1].sha1);
}
-static void cmd_from_existing(struct branch *b)
+static void parse_from_existing(struct branch *b)
{
if (is_null_sha1(b->sha1)) {
hashclr(b->branch_tree.versions[0].sha1);
buf = read_object_with_reference(b->sha1,
commit_type, &size, b->sha1);
- cmd_from_commit(b, buf, size);
+ parse_from_commit(b, buf, size);
free(buf);
}
}
-static int cmd_from(struct branch *b)
+static int parse_from(struct branch *b)
{
const char *from;
struct branch *s;
if (oe->pack_id != MAX_PACK_ID) {
unsigned long size;
char *buf = gfi_unpack_entry(oe, &size);
- cmd_from_commit(b, buf, size);
+ parse_from_commit(b, buf, size);
free(buf);
} else
- cmd_from_existing(b);
+ parse_from_existing(b);
} else if (!get_sha1(from, b->sha1))
- cmd_from_existing(b);
+ parse_from_existing(b);
else
die("Invalid ref name or SHA1 expression: %s", from);
return 1;
}
-static struct hash_list *cmd_merge(unsigned int *count)
+static struct hash_list *parse_merge(unsigned int *count)
{
struct hash_list *list = NULL, *n, *e = e;
const char *from;
return list;
}
-static void cmd_new_commit(void)
+static void parse_new_commit(void)
{
static struct strbuf msg = STRBUF_INIT;
struct branch *b;
b = new_branch(sp);
read_next_command();
- cmd_mark();
+ parse_mark();
if (!prefixcmp(command_buf.buf, "author ")) {
author = parse_ident(command_buf.buf + 7);
read_next_command();
}
if (!committer)
die("Expected committer but didn't get one");
- cmd_data(&msg);
+ parse_data(&msg);
read_next_command();
- cmd_from(b);
- merge_list = cmd_merge(&merge_count);
+ parse_from(b);
+ merge_list = parse_merge(&merge_count);
/* ensure the branch is active/loaded */
if (!b->branch_tree.tree || !max_active_branches) {
b->last_commit = object_count_by_type[OBJ_COMMIT];
}
-static void cmd_new_tag(void)
+static void parse_new_tag(void)
{
static struct strbuf msg = STRBUF_INIT;
char *sp;
/* tag payload/message */
read_next_command();
- cmd_data(&msg);
+ parse_data(&msg);
/* build the tag object */
strbuf_reset(&new_data);
t->pack_id = pack_id;
}
-static void cmd_reset_branch(void)
+static void parse_reset_branch(void)
{
struct branch *b;
char *sp;
else
b = new_branch(sp);
read_next_command();
- if (!cmd_from(b) && command_buf.len > 0)
+ parse_from(b);
+ if (command_buf.len > 0)
unread_command_buf = 1;
}
-static void cmd_checkpoint(void)
+static void parse_checkpoint(void)
{
if (object_count) {
cycle_packfile();
skip_optional_lf();
}
-static void cmd_progress(void)
+static void parse_progress(void)
{
fwrite(command_buf.buf, 1, command_buf.len, stdout);
fputc('\n', stdout);
{
unsigned int i, show_stats = 1;
+ setup_git_directory();
git_config(git_pack_config);
if (!pack_compression_seen && core_compression_seen)
pack_compression_level = core_compression_level;
set_die_routine(die_nicely);
while (read_next_command() != EOF) {
if (!strcmp("blob", command_buf.buf))
- cmd_new_blob();
+ parse_new_blob();
else if (!prefixcmp(command_buf.buf, "commit "))
- cmd_new_commit();
+ parse_new_commit();
else if (!prefixcmp(command_buf.buf, "tag "))
- cmd_new_tag();
+ parse_new_tag();
else if (!prefixcmp(command_buf.buf, "reset "))
- cmd_reset_branch();
+ parse_reset_branch();
else if (!strcmp("checkpoint", command_buf.buf))
- cmd_checkpoint();
+ parse_checkpoint();
else if (!prefixcmp(command_buf.buf, "progress "))
- cmd_progress();
+ parse_progress();
else
die("Unsupported command: %s", command_buf.buf);
}