Skip to contentSkip to conversation

rebase: ignore failures from "gc --auto"

PATCH In review Jeff King 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore

Jeff King

author
#0 lore raw

PATCH 1/1 rebase: ignore failures from "gc --auto"

After rebasing, we call "gc --auto" to clean up if we created a lot of loose objects. However, we do so inside an &&-chain. If "gc --auto" fails (e.g., because a previous background gc blocked us by leaving "gc.log" in place), then:

1. We will fail to clean up the state directory, leaving the user stuck in the rebase forever (even "git am --abort" doesn't work, because it calls "gc --auto"!).

2. In some cases, we may return a bogus exit code from rebase, indicating failure when everything except the auto-gc succeeded.

We can fix this by ignoring the exit code of "gc --auto".

---
This bit me just now. The real blocker was "you have too many loose objects, run 'git prune'" left in the gc.log file.

It looks like this is the only "gc --auto" we call from a shell script, and all of the C callers already ignore the exit code. So no other spots need a similar fix.

 git-rebase.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-rebase.sh +1 -1
index af7ba5f..cf60c43 100755
@@ -176,7 +176,7 @@ You can run "git stash pop" or "git stash drop" at any time.
 
 finish_rebase () {
 	apply_autostash &&
-	git gc --auto &&
+	{ git gc --auto || true; } &&
 	rm -rf "$state_dir"
 }
 
Signature · 1 line
2.7.0.242.gdeece69
author
#1 lore raw
Quoted 2 lines · Jeff King

This bit me just now. The real blocker was "you have too many loose objects, run 'git prune'" left in the gc.log file.

Which was of course annoying in itself. I was running a scripted set of rebases, so even with this fix, my terminal got spammed with the "whoops, we can't auto-gc" message over and over.

The worst part is that when I looked at .git/objects, there were a lot of objects, but most of them could be cleaned up! I wonder if too_many_loose_objects() should take into account the prune time of the objects it finds. I also wonder how I got into that situation, since that check should come right _after_ we've finished running "gc". I wonder if I had two backgrounded auto-gc's racing or something.

-Peff

#2 lore raw
In reply to Jeff King
Quoted 9 lines · Jeff King

After rebasing, we call "gc --auto" to clean up if we created a lot of loose objects. However, we do so inside an &&-chain. If "gc --auto" fails (e.g., because a previous background gc blocked us by leaving "gc.log" in place), then:

1. We will fail to clean up the state directory, leaving the user stuck in the rebase forever (even "git am --abort" doesn't work, because it calls "gc --auto"!).

Just curious, but do you mean "git rebase --abort" ?

Thanks,
Rodrigo

author
#3 lore raw
Quoted 7 lines · Rodrigo Campos
Quoted 6 lines · Jeff King

After rebasing, we call "gc --auto" to clean up if we created a lot of loose objects. However, we do so inside an &&-chain. If "gc --auto" fails (e.g., because a previous background gc blocked us by leaving "gc.log" in place), then:

Quoted 5 lines
Quoted 3 lines

1. We will fail to clean up the state directory, leaving the user stuck in the rebase forever (even "git am --abort" doesn't work, because it calls "gc --auto"!).

Just curious, but do you mean "git rebase --abort" ?

Yeah, sorry, I did mean "git rebase --abort".

-Peff