From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Subject: [RFC/PATCH] git-prune: never lose objects reachable from our refs.
Date: Thu, 08 Dec 2005 23:25:10 -0800 [thread overview]
Message-ID: <7vmzja91gp.fsf_-_@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7voe3r9krf.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Thu, 08 Dec 2005 16:28:20 -0800")
Explicit <head> arguments to git-prune replaces, instead of
extends, the list of heads used for reachability analysis by
fsck-objects. By giving a subset of heads by mistake, objects
reachable only from other heads can be removed, resulting in a
corrupted repository.
This commit stops replacing the list of heads, and makes the
command line arguments to add to them instead for safety.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
* I think this is preferable in general than leaving the
end-user tool too sharp-edged and dangerous.
Documentation/git-prune.txt | 27 +++++++++------------------
git-prune.sh | 6 +++++-
2 files changed, 14 insertions(+), 19 deletions(-)
2b86976bfd6e42609692d57fffaef72bd985c23a
diff --git a/Documentation/git-prune.txt b/Documentation/git-prune.txt
index 05c8d49..f694fcb 100644
--- a/Documentation/git-prune.txt
+++ b/Documentation/git-prune.txt
@@ -13,10 +13,11 @@ SYNOPSIS
DESCRIPTION
-----------
-This runs `git-fsck-objects --unreachable` using the heads
-specified on the command line (or `$GIT_DIR/refs/heads/\*` and
-`$GIT_DIR/refs/tags/\*` if none is specified), and prunes all
-unreachable objects from the object database. In addition, it
+This runs `git-fsck-objects --unreachable` using all the refs
+available in `$GIT_DIR/refs`, optionally with additional set of
+objects specified on the command line, and prunes all
+objects unreachable from any of these head objects from the object database.
+In addition, it
prunes the unpacked objects that are also found in packs by
running `git prune-packed`.
@@ -31,29 +32,19 @@ OPTIONS
Do not interpret any more arguments as options.
<head>...::
- Instead of keeping objects
+ In addition to objects
reachable from any of our references, keep objects
- reachable from only listed <head>s.
-+
-Note that the explicitly named <head>s are *not* appended to the
-default set of references, but they replace them. In general you
-would want to say `git prune $(git-rev-parse --all) extra1
-extra2` to keep chains of commits leading to extra1, extra2,
-... in addition to what are reachable from your own refs.
-Saying `git prune extra1 extra2` would *lose* objects reachable
-only from the usual refs, which is usually not what you want.
-
+ reachable from listed <head>s.
EXAMPLE
-------
-To prune objects not used by your repository and another that
+To prune objects not used by your repository nor another that
borrows from your repository via its
`.git/objects/info/alternates`:
------------
-$ git prune $(git-rev-parse --all) \
- $(cd ../another && $(git-rev-parse --all))
+$ git prune $(cd ../another && $(git-rev-parse --all))
------------
Author
diff --git a/git-prune.sh b/git-prune.sh
index 1fd8c73..7e7f0ad 100755
--- a/git-prune.sh
+++ b/git-prune.sh
@@ -16,7 +16,11 @@ do
done
sync
-git-fsck-objects --full --cache --unreachable "$@" |
+case "$#" in
+0) git-fsck-objects --full --cache --unreachable ;;
+*) git-fsck-objects --full --cache --unreachable $(git-rev-parse --all) "$@" ;;
+esac |
+
sed -ne '/unreachable /{
s/unreachable [^ ][^ ]* //
s|\(..\)|\1/|p
--
0.99.9.GIT
next prev parent reply other threads:[~2005-12-09 7:25 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-08 23:28 [PATCH 0/17] Documentation fixes in response to my previous listing Nikolai Weibull
2005-12-08 23:28 ` [PATCH 1/17] Document the --non-empty command-line option to git-pack-objects Nikolai Weibull
2005-12-08 23:28 ` [PATCH 2/17] Fix the description of --utf8 and --keep to git-am Nikolai Weibull
2005-12-08 23:28 ` [PATCH 3/17] Use uniform description for the '--' option Nikolai Weibull
2005-12-08 23:28 ` [PATCH 4/17] Documentation/git-commit.txt: Add long options and -- to documentation Nikolai Weibull
2005-12-08 23:28 ` [PATCH 5/17] Documentation/git-verify-pack.txt: added documentation for -- Nikolai Weibull
2005-12-08 23:28 ` [PATCH 6/17] Document the [<head>...] and -- arguments to git-prune Nikolai Weibull
2005-12-08 23:28 ` [PATCH 7/17] Documentation/git-cvsimport.txt: Fix a slight glitch in description heading Nikolai Weibull
2005-12-08 23:28 ` [PATCH 8/17] Documentation/git-cherry-pick: Add --replay and --no-commit Nikolai Weibull
2005-12-08 23:28 ` [PATCH 9/17] Add documentation for git-revert and git-cherry-pick Nikolai Weibull
2005-12-08 23:28 ` [PATCH 10/17] Add documentation for the --topo-order option to git-show-branch Nikolai Weibull
2005-12-08 23:28 ` [PATCH 11/17] Documentation/git-format-patch.txt: Add --signoff, --check, and long option-names Nikolai Weibull
2005-12-08 23:28 ` [PATCH 12/17] Documentation/git-ls-remote.txt: Add -h and -t Nikolai Weibull
2005-12-08 23:28 ` [PATCH 13/17] Documentation/git-repack.txt: Add -l and -n Nikolai Weibull
2005-12-08 23:28 ` [PATCH 14/17] Documentation/git-http-fetch.txt: Document the commit-id argument Nikolai Weibull
2005-12-08 23:28 ` [PATCH 15/17] Documentation/git-update-server-info.txt: Add -f alias for --force to documentation Nikolai Weibull
2005-12-08 23:28 ` [PATCH 16/17] Documentation/git-tag.txt: Fix the order of sections (DESCRIPTION should come before OPTIONS) Nikolai Weibull
2005-12-08 23:28 ` [PATCH 17/17] Documentation/git-read-tree.txt: Add --reset to SYNOPSIS Nikolai Weibull
2005-12-08 23:49 ` [PATCH 6/17] Document the [<head>...] and -- arguments to git-prune Junio C Hamano
2005-12-08 23:56 ` Junio C Hamano
2005-12-09 0:28 ` Junio C Hamano
2005-12-09 7:25 ` Junio C Hamano [this message]
2005-12-09 19:39 ` [RFC/PATCH] git-prune: never lose objects reachable from our refs Peter Eriksen
2005-12-09 20:38 ` Junio C Hamano
2005-12-09 0:50 ` [PATCH 6/17] Document the [<head>...] and -- arguments to git-prune Nikolai Weibull
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vmzja91gp.fsf_-_@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).