Run garbage collection with loose object pruning after svn dcommit
PATCH 2/2 Run garbage collection with loose object pruning after svn dcommit
git-svn dcommit, by virtue of rewriting history to insert svn revision IDs, leaves old commits dangling. Since dcommit is already unsafe to run concurrently with other git commands, no additional risk is introduced by making it prune those old objects as needed.
---
This is in response to a colleague who complained that, after I installed the latest git release, he was getting lots of "too many unreachable loose objects" errors from the new "git gc --auto" run. Those objects turned out to be dangling commits from a year's worth of git-svn usage, since every git-svn commit will abandon at least one existing commit in order to rewrite it with the svn version data.
git-svn.perl | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
git-svn.perl +6 -0
@@ -441,6 +441,12 @@ sub cmd_dcommit { } command_noisy(@finish, $gs->refname); $last_rev = $cmt_rev; + + # rebase will have made the just-committed revisions + # unreachable; over time that can build up lots of + # loose objects in the repo. prune is unsafe to run + # concurrently but so is dcommit. + command_noisy(qw/gc --auto --prune/); } } }
Signature · 1 line
1.5.3.4.203.gcc61a
Quoted 6 lines · Steven Grimm
git-svn dcommit, by virtue of rewriting history to insert svn revision IDs, leaves old commits dangling. Since dcommit is already unsafe to run concurrently with other git commands, no additional risk is introduced by making it prune those old objects as needed.
Signed-off-by Steven Grimm <[email protected]>
Quoted 9 lines
---
This is in response to a colleague who complained that, after I installed the latest git release, he was getting lots of "too many unreachable loose objects" errors from the new "git gc --auto" run. Those objects turned out to be dangling commits from a year's worth of git-svn usage, since every git-svn commit will abandon at least one existing commit in order to rewrite it with the svn version data.
I don't like the automatic prune. What if someone has other objects in there which shouldn't be pruned? Making git svn dcommit doing the prune would be at least suprising, because how is one supposed to know that doing a commit into svn will prune all your precious objects?
Sure, I can unterstand from where you are coming from, but I'd prefere if this could be specified on a case by case basis, e.g. from the cmdline or as a config option.
-Peter
Quoted 28 lines
git-svn.perl | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)git-svn.perl +6
-0@@ -441,6 +441,12 @@ sub cmd_dcommit { } command_noisy(@finish, $gs->refname); $last_rev = $cmt_rev; + + # rebase will have made the just-committed revisions + # unreachable; over time that can build up lots of + # loose objects in the repo. prune is unsafe to run + # concurrently but so is dcommit. + command_noisy(qw/gc --auto --prune/); } } }Signature · 6 lines
1.5.3.4.203.gcc61a - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Peter Baumann
I don't like the automatic prune. What if someone has other objects in there which shouldn't be pruned? Making git svn dcommit doing the prune would be at least suprising, because how is one supposed to know that doing a commit into svn will prune all your precious objects?
"git commit" already does garbage collection, so we've already set a precedent for a commit operation also doing some cleanup at the end. However, you're correct that this cleanup behavior (and the way to turn it off) should be documented so that there's some way to know about it. Doc patch forthcoming.
Quoted 4 lines
Sure, I can unterstand from where you are coming from, but I'd prefere if this could be specified on a case by case basis, e.g. from the cmdline or as a config option.
This code (by virtue of only doing the prune if the "too many loose objects" test succeeds) will obey the existing gc.auto config option. So it's already possible to turn off as is. I'll note that in the doc patch.
-Steve
[PATCH 3/2] Document the fact that git-svn now runs git-gc
--- Documentation/git-svn.txt | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
Documentation/git-svn.txt +9 -1
@@ -125,7 +125,15 @@ and have no uncommitted changes. alternative to HEAD. This is advantageous over 'set-tree' (below) because it produces cleaner, more linear history. -+ + +When the commit is finished, gitlink:git-gc[1] is run with the +`--prune` and `--auto` options to clean up the git object database, +including removing old unreachable objects (some of which are +created by the process of committing to SVN.) Set the `gc.auto` +config option to 0 if you don't want your repository to be cleaned, +e.g., because you are intentionally keeping unreachable objects in +your repository. + --no-rebase;; After committing, do not rebase or reset. --
Signature · 1 line
1.5.3.4.203.gcc61a
Quoted 7 lines · Steven Grimm
Quoted 5 lines · Peter Baumann
I don't like the automatic prune. What if someone has other objects in there which shouldn't be pruned? Making git svn dcommit doing the prune would be at least suprising, because how is one supposed to know that doing a commit into svn will prune all your precious objects?
Quoted 6 lines
"git commit" already does garbage collection, so we've already set a precedent for a commit operation also doing some cleanup at the end. However, you're correct that this cleanup behavior (and the way to turn it off) should be documented so that there's some way to know about it. Doc patch forthcoming.
That's new to me. Glancing over git-commit.sh, I could only find a 'git-gc --auto', but no prune. I am not against doing a 'git gc --auto', but I am against the --prune, because this could make shared repositories unfunctional.
-Peter
Quoted 5 lines · Peter Baumann
That's new to me. Glancing over
git-commit.sh, I could only find a 'git-gc --auto', but no prune. I am not against doing a 'git gc --auto', but I am against the --prune, because this could make shared repositories unfunctional.
Does anyone run "git svn dcommit" from a shared repository? That is the only command that will trigger this code path.
Given that you lose all the svn metadata if you do "git clone" (or "git clone -s") on a git-svn-managed repository, it's not clear to me that anyone would ever be bitten by this. Counterexamples welcome, of course.
How would you feel about a separate config option to specifically enable auto-pruning, and having "git svn clone" set that option by default? Presumably anyone who is setting up a shared git-svn repository will be up to the task of disabling the option.
-Steve
Quoted 10 lines · Steven Grimm
Quoted 5 lines · Peter Baumann
That's new to me. Glancing over
git-commit.sh, I could only find a 'git-gc --auto', but no prune. I am not against doing a 'git gc --auto', but I am against the --prune, because this could make shared repositories unfunctional.Does anyone run "git svn dcommit" from a shared repository? That is the only command that will trigger this code path.
Quoted 9 lines
Given that you lose all the svn metadata if you do "git clone" (or "git clone -s") on a git-svn-managed repository, it's not clear to me that anyone would ever be bitten by this. Counterexamples welcome, of course.
How would you feel about a separate config option to specifically enable auto-pruning, and having "git svn clone" set that option by default? Presumably anyone who is setting up a shared git-svn repository will be up to the task of disabling the option.
Sorry, I looked at 'git commit' (as you said in your mail) and not 'git-svn dcommit'. Looking now at git-svn, I could see the there is only done a git-repack if the user *explicitly* asked for it on the cmdline specifying --repack. For this repack run, the default parameter includes -d and no --prune, so I do not think that we are doing a --prune run if we where not _explicitly_ asked for it. As I said, I am totaly fine with doing a 'git-gc --auto', but I am a little worried about the --prune.
We advertise everywhere that GIT adds only new content/objects/data to the repository and *never* deletes anything itself in the repo and now you want to do a --prune, wich obviously *does* delete data behind the users back in a dcommit/fetch operation, which no one would think of that these commands do have anything in common with deleting data. And this worries me.
-Peter
Quoted 6 lines · Steven Grimm
git-svn dcommit, by virtue of rewriting history to insert svn revision IDs, leaves old commits dangling. Since dcommit is already unsafe to run concurrently with other git commands, no additional risk is introduced by making it prune those old objects as needed.
Signed-off-by Steven Grimm <[email protected]>
Quoted 8 lines
---
This is in response to a colleague who complained that, after I installed the latest git release, he was getting lots of "too many unreachable loose objects" errors from the new "git gc --auto" run. Those objects turned out to be dangling commits from a year's worth of git-svn usage, since every git-svn commit will abandon at least one existing commit in order to rewrite it with the svn version data.
I'm not a fan of automatic gc in general, but I understand it can help new users. So as long as clueful users can easily disable it, then it's fine by me...
Quoted 10 lines
git-svn.perl | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)git-svn.perl +0
-0@@ -441,6 +441,12 @@ sub cmd_dcommit { } command_noisy(@finish, $gs->refname);
git-svn.perl sub cmd_dcommit { · line 452
Quoted 10 lines
git-svn.perl +6
-0$last_rev = $cmt_rev; + + # rebase will have made the just-committed revisions + # unreachable; over time that can build up lots of + # loose objects in the repo. prune is unsafe to run + # concurrently but so is dcommit. + command_noisy(qw/gc --auto --prune/); } } }
This is better called outside of this loop. We now do a rebase after every revision committed (which gets us even more dangling commits); but we only want to call git-gc after everything is committed.
It'll be faster since git-gc is only invoked once, and if git-gc takes a very long time to repack, we won't have to worry about timing out a SVN network connection. It'll also reduce the window for somebody else to commit a conflicting change that'll cause dcommit to fail midway through.
As far as Peter's concerns for shared repositories go, I'm not sure...
I've never been comfortable with shared repositories myself (even in a pure git environment without git-svn) and always just preferred using full clones or copies[1] myself so I could rm -r any working directory and not worry about any other repositories relying on it.
[1] - I usually go about using cp -al + libflcow :)
Signature · 1 line
Eric Wong
Quoted 25 lines · Steven Grimm
git-svn dcommit, by virtue of rewriting history to insert svn revision IDs, leaves old commits dangling. Since dcommit is already unsafe to run concurrently with other git commands, no additional risk is introduced by making it prune those old objects as needed.
Signed-off-by Steven Grimm <[email protected]>---
This is in response to a colleague who complained that, after I installed the latest git release, he was getting lots of "too many unreachable loose objects" errors from the new "git gc --auto" run. Those objects turned out to be dangling commits from a year's worth of git-svn usage, since every git-svn commit will abandon at least one existing commit in order to rewrite it with the svn version data.
git-svn.perl | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)git-svn.perl +0
-0@@ -441,6 +441,12 @@ sub cmd_dcommit { } command_noisy(@finish, $gs->refname);
git-svn.perl sub cmd_dcommit { · line 452
Quoted 10 lines
git-svn.perl +6
-0$last_rev = $cmt_rev; + + # rebase will have made the just-committed revisions + # unreachable; over time that can build up lots of + # loose objects in the repo. prune is unsafe to run + # concurrently but so is dcommit. + command_noisy(qw/gc --auto --prune/); } } }
I'd be surprised if this would ever prune anything, as git doesn't throw out objects reachable by reflog (or, I assume, any of the objects reachable from objects reachable from reflog).
Signature · 3 lines
Andreas Ericsson [email protected] OP5 AB www.op5.se Tel: +46 8-230225 Fax: +46 8-230231
Hi,
Quoted 32 lines · Andreas Ericsson
Quoted 31 lines · Steven Grimm
git-svn dcommit, by virtue of rewriting history to insert svn revision IDs, leaves old commits dangling. Since dcommit is already unsafe to run concurrently with other git commands, no additional risk is introduced by making it prune those old objects as needed.
Signed-off-by Steven Grimm <[email protected]>---
This is in response to a colleague who complained that, after I installed the latest git release, he was getting lots of "too many unreachable loose objects" errors from the new "git gc --auto" run. Those objects turned out to be dangling commits from a year's worth of git-svn usage, since every git-svn commit will abandon at least one existing commit in order to rewrite it with the svn version data.
git-svn.perl | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)git-svn.perl +5
-0@@ -441,6 +441,12 @@ sub cmd_dcommit { } command_noisy(@finish, $gs->refname); $last_rev = $cmt_rev; + + # rebase will have made the just-committed revisions + # unreachable; over time that can build up lots of + # loose objects in the repo. prune is unsafe to run + # concurrently but so is dcommit.
Quoted 8 lines
git-svn.perl sub cmd_dcommit { · line 452
Quoted 4 lines
git-svn.perl +1
-0+ command_noisy(qw/gc --auto --prune/); } } }I'd be surprised if this would ever prune anything, as git doesn't throw out objects reachable by reflog (or, I assume, any of the objects reachable from objects reachable from reflog).
It will so, in due time. Reflogs have an expiry date, and will be culled by git gc --auto. So if you dcommit often (which I do), the objects will be pruned, eventually.
Ciao,
Dscho