mirror of
https://github.com/git/git
synced 2024-07-07 19:39:27 +00:00
fsck: --no-dangling omits "dangling object" information
The default output from "fsck" is often overwhelmed by informational message on dangling objects, especially if you do not repack often, and a real error can easily be buried. Add "--no-dangling" option to omit them, and update the user manual to demonstrate its use. Based on a patch by Clemens Buchacher, but reverted the part to change the default to --no-dangling, which is unsuitable for the first patch. The usual three-step procedure to break the backward compatibility over time needs to happen on top of this, if we were to go in that direction. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
ba998d33e2
commit
c6a13b2c86
|
@ -11,7 +11,7 @@ SYNOPSIS
|
||||||
[verse]
|
[verse]
|
||||||
'git fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
|
'git fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
|
||||||
[--[no-]full] [--strict] [--verbose] [--lost-found]
|
[--[no-]full] [--strict] [--verbose] [--lost-found]
|
||||||
[--[no-]progress] [<object>*]
|
[--[no-]dangling] [--[no-]progress] [<object>*]
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
|
@ -30,6 +30,11 @@ index file, all SHA1 references in .git/refs/*, and all reflogs (unless
|
||||||
Print out objects that exist but that aren't reachable from any
|
Print out objects that exist but that aren't reachable from any
|
||||||
of the reference nodes.
|
of the reference nodes.
|
||||||
|
|
||||||
|
--dangling::
|
||||||
|
--no-dangling::
|
||||||
|
Print objects that exist but that are never 'directly' used (default).
|
||||||
|
`--no-dangling` can be used to squech this information from the output.
|
||||||
|
|
||||||
--root::
|
--root::
|
||||||
Report root nodes.
|
Report root nodes.
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ OPTIONS
|
||||||
Especially useful when packing a repository that is used
|
Especially useful when packing a repository that is used
|
||||||
for private development. Use
|
for private development. Use
|
||||||
with '-d'. This will clean up the objects that `git prune`
|
with '-d'. This will clean up the objects that `git prune`
|
||||||
leaves behind, but `git fsck --full` shows as
|
leaves behind, but `git fsck --full --dangling` shows as
|
||||||
dangling.
|
dangling.
|
||||||
+
|
+
|
||||||
Note that users fetching over dumb protocols will have to fetch the
|
Note that users fetching over dumb protocols will have to fetch the
|
||||||
|
|
|
@ -1582,7 +1582,7 @@ Checking the repository for corruption
|
||||||
|
|
||||||
The linkgit:git-fsck[1] command runs a number of self-consistency checks
|
The linkgit:git-fsck[1] command runs a number of self-consistency checks
|
||||||
on the repository, and reports on any problems. This may take some
|
on the repository, and reports on any problems. This may take some
|
||||||
time. The most common warning by far is about "dangling" objects:
|
time.
|
||||||
|
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
$ git fsck
|
$ git fsck
|
||||||
|
@ -1597,9 +1597,11 @@ dangling tree b24c2473f1fd3d91352a624795be026d64c8841f
|
||||||
...
|
...
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
Dangling objects are not a problem. At worst they may take up a little
|
You will see informational messages on dangling objects. They are objects
|
||||||
extra disk space. They can sometimes provide a last-resort method for
|
that still exist in the repository but are no longer referenced by any of
|
||||||
recovering lost work--see <<dangling-objects>> for details.
|
your branches, and can (and will) be removed after a while with "gc".
|
||||||
|
You can run `git fsck --no-dangling` to supress these messages, and still
|
||||||
|
view real errors.
|
||||||
|
|
||||||
[[recovering-lost-changes]]
|
[[recovering-lost-changes]]
|
||||||
Recovering lost changes
|
Recovering lost changes
|
||||||
|
@ -3295,15 +3297,12 @@ it is with linkgit:git-fsck[1]; this may be time-consuming.
|
||||||
Assume the output looks like this:
|
Assume the output looks like this:
|
||||||
|
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
$ git fsck --full
|
$ git fsck --full --no-dangling
|
||||||
broken link from tree 2d9263c6d23595e7cb2a21e5ebbb53655278dff8
|
broken link from tree 2d9263c6d23595e7cb2a21e5ebbb53655278dff8
|
||||||
to blob 4b9458b3786228369c63936db65827de3cc06200
|
to blob 4b9458b3786228369c63936db65827de3cc06200
|
||||||
missing blob 4b9458b3786228369c63936db65827de3cc06200
|
missing blob 4b9458b3786228369c63936db65827de3cc06200
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
(Typically there will be some "dangling object" messages too, but they
|
|
||||||
aren't interesting.)
|
|
||||||
|
|
||||||
Now you know that blob 4b9458b3 is missing, and that the tree 2d9263c6
|
Now you know that blob 4b9458b3 is missing, and that the tree 2d9263c6
|
||||||
points to it. If you could find just one copy of that missing blob
|
points to it. If you could find just one copy of that missing blob
|
||||||
object, possibly in some other repository, you could move it into
|
object, possibly in some other repository, you could move it into
|
||||||
|
|
|
@ -29,6 +29,7 @@ static int errors_found;
|
||||||
static int write_lost_and_found;
|
static int write_lost_and_found;
|
||||||
static int verbose;
|
static int verbose;
|
||||||
static int show_progress = -1;
|
static int show_progress = -1;
|
||||||
|
static int show_dangling = 1;
|
||||||
#define ERROR_OBJECT 01
|
#define ERROR_OBJECT 01
|
||||||
#define ERROR_REACHABLE 02
|
#define ERROR_REACHABLE 02
|
||||||
#define ERROR_PACK 04
|
#define ERROR_PACK 04
|
||||||
|
@ -221,8 +222,9 @@ static void check_unreachable_object(struct object *obj)
|
||||||
* start looking at, for example.
|
* start looking at, for example.
|
||||||
*/
|
*/
|
||||||
if (!obj->used) {
|
if (!obj->used) {
|
||||||
printf("dangling %s %s\n", typename(obj->type),
|
if (show_dangling)
|
||||||
sha1_to_hex(obj->sha1));
|
printf("dangling %s %s\n", typename(obj->type),
|
||||||
|
sha1_to_hex(obj->sha1));
|
||||||
if (write_lost_and_found) {
|
if (write_lost_and_found) {
|
||||||
char *filename = git_path("lost-found/%s/%s",
|
char *filename = git_path("lost-found/%s/%s",
|
||||||
obj->type == OBJ_COMMIT ? "commit" : "other",
|
obj->type == OBJ_COMMIT ? "commit" : "other",
|
||||||
|
@ -614,6 +616,7 @@ static char const * const fsck_usage[] = {
|
||||||
static struct option fsck_opts[] = {
|
static struct option fsck_opts[] = {
|
||||||
OPT__VERBOSE(&verbose, "be verbose"),
|
OPT__VERBOSE(&verbose, "be verbose"),
|
||||||
OPT_BOOLEAN(0, "unreachable", &show_unreachable, "show unreachable objects"),
|
OPT_BOOLEAN(0, "unreachable", &show_unreachable, "show unreachable objects"),
|
||||||
|
OPT_BOOL(0, "dangling", &show_dangling, "show dangling objects"),
|
||||||
OPT_BOOLEAN(0, "tags", &show_tags, "report tags"),
|
OPT_BOOLEAN(0, "tags", &show_tags, "report tags"),
|
||||||
OPT_BOOLEAN(0, "root", &show_root, "report root nodes"),
|
OPT_BOOLEAN(0, "root", &show_root, "report root nodes"),
|
||||||
OPT_BOOLEAN(0, "cache", &keep_cache_objects, "make index objects head nodes"),
|
OPT_BOOLEAN(0, "cache", &keep_cache_objects, "make index objects head nodes"),
|
||||||
|
|
|
@ -27,12 +27,8 @@ test_expect_success 'loose objects borrowed from alternate are not missing' '
|
||||||
git init &&
|
git init &&
|
||||||
echo ../../../.git/objects >.git/objects/info/alternates &&
|
echo ../../../.git/objects >.git/objects/info/alternates &&
|
||||||
test_commit C fileC one &&
|
test_commit C fileC one &&
|
||||||
git fsck >../out 2>&1
|
git fsck --no-dangling >../actual 2>&1
|
||||||
) &&
|
) &&
|
||||||
{
|
|
||||||
grep -v dangling out >actual ||
|
|
||||||
:
|
|
||||||
} &&
|
|
||||||
test_cmp empty actual
|
test_cmp empty actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user