int is_repository_shallow(struct repository *r)
{
- /*
- * NEEDSWORK: This function updates
- * r->parsed_objects->{is_shallow,shallow_stat} as a side effect but
- * there is no corresponding function to clear them when the shallow
- * file is updated.
- */
-
FILE *fp;
char buf[1024];
const char *path = r->parsed_objects->alternate_shallow_file;
return r->parsed_objects->is_shallow;
}
+static void reset_repository_shallow(struct repository *r)
+{
+ r->parsed_objects->is_shallow = -1;
+ stat_validity_clear(r->parsed_objects->shallow_stat);
+}
+
+int commit_shallow_file(struct repository *r, struct lock_file *lk)
+{
+ int res = commit_lock_file(lk);
+ reset_repository_shallow(r);
+ return res;
+}
+
+void rollback_shallow_file(struct repository *r, struct lock_file *lk)
+{
+ rollback_lock_file(lk);
+ reset_repository_shallow(r);
+}
+
/*
* TODO: use "int" elemtype instead of "int *" when/if commit-slab
* supports a "valid" flag.
if (write_in_full(fd, sb.buf, sb.len) < 0)
die_errno("failed to write to %s",
get_lock_file_path(&shallow_lock));
- commit_lock_file(&shallow_lock);
+ commit_shallow_file(the_repository, &shallow_lock);
} else {
unlink(git_path_shallow(the_repository));
- rollback_lock_file(&shallow_lock);
+ rollback_shallow_file(the_repository, &shallow_lock);
}
strbuf_release(&sb);
}