summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/checkout.c6
-rw-r--r--builtin/gc.c7
-rw-r--r--builtin/pack-redundant.c6
3 files changed, 13 insertions, 6 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 9b82119129..c9ba23c279 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -480,9 +480,11 @@ static int checkout_paths(const struct checkout_opts *opts,
* with the hex of the commit (whether it's in `...` form or
* not) for the run_add_interactive() machinery to work
* properly. However, there is special logic for the HEAD case
- * so we mustn't replace that.
+ * so we mustn't replace that. Also, when we were given a
+ * tree-object, new_branch_info->commit would be NULL, but we
+ * do not have to do any replacement, either.
*/
- if (rev && strcmp(rev, "HEAD"))
+ if (rev && new_branch_info->commit && strcmp(rev, "HEAD"))
rev = oid_to_hex_r(rev_oid, &new_branch_info->commit->object.oid);
if (opts->checkout_index && opts->checkout_worktree)
diff --git a/builtin/gc.c b/builtin/gc.c
index b57fda4924..4c24f41852 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -1554,11 +1554,10 @@ static int update_background_schedule(int run_maintenance)
while (!strbuf_getline_lf(&line, cron_list)) {
if (!in_old_region && !strcmp(line.buf, BEGIN_LINE))
in_old_region = 1;
- if (in_old_region)
- continue;
- fprintf(cron_in, "%s\n", line.buf);
- if (in_old_region && !strcmp(line.buf, END_LINE))
+ else if (in_old_region && !strcmp(line.buf, END_LINE))
in_old_region = 0;
+ else if (!in_old_region)
+ fprintf(cron_in, "%s\n", line.buf);
}
if (run_maintenance) {
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index 3e70f2a4c1..9fcea3e253 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -473,6 +473,12 @@ static void cmp_local_packs(void)
{
struct pack_list *subset, *pl = local_packs;
+ /* only one packfile */
+ if (!pl->next) {
+ llist_init(&pl->unique_objects);
+ return;
+ }
+
while ((subset = pl)) {
while ((subset = subset->next))
cmp_two_packs(pl, subset);