author | Junio C Hamano <gitster@pobox.com> | |
Sat, 25 Jul 2009 07:45:03 +0000 (00:45 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 25 Jul 2009 07:45:03 +0000 (00:45 -0700) |
* js/maint-graft-unhide-true-parents:
git repack: keep commits hidden by a graft
Add a test showing that 'git repack' throws away grafted-away parents
Conflicts:
git-repack.sh
git repack: keep commits hidden by a graft
Add a test showing that 'git repack' throws away grafted-away parents
Conflicts:
git-repack.sh
index 7d4c1a75562de80aa80dfbfa665330b14ec948c6..2e4992970e84a1789cb97d35969976d12e5a30e1 100644 (file)
[verse]
'git pack-objects' [-q] [--no-reuse-delta] [--delta-base-offset] [--non-empty]
[--local] [--incremental] [--window=N] [--depth=N] [--all-progress]
- [--revs [--unpacked | --all]*] [--stdout | base-name] < object-list
+ [--revs [--unpacked | --all]*] [--stdout | base-name]
+ [--keep-true-parents] < object-list
DESCRIPTION
to force the version for the generated pack index, and to force
64-bit index entries on objects located above the given offset.
+--keep-true-parents::
+ With this option, parents that are hidden by grafts are packed
+ nevertheless.
+
Author
------
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index a27c2f6277cd55951cec5d9b5b207df426ed9ff0..ef4bf6bc14aadffcd85999c2eca59e5a0e7e6451 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
die("bad %s", arg);
continue;
}
+ if (!strcmp(arg, "--keep-true-parents")) {
+ grafts_replace_parents = 0;
+ continue;
+ }
usage(pack_usage);
}
index c72f125bd4ccd8f5fe38c21a57ac611115519b0a..e6c7f3307d09e592aa5bcc63fe6d372aa54a5da3 100644 (file)
--- a/cache.h
+++ b/cache.h
extern enum object_creation_mode object_creation_mode;
+extern int grafts_replace_parents;
+
#define GIT_REPO_VERSION 0
extern int repository_format_version;
extern int check_repository_format(void);
diff --git a/commit.c b/commit.c
index a47fb4da271beaf5595b6bbbe41f94bad08f404d..e2bcbe814936989e7a86018e46ed6ca86f4c1f10 100644 (file)
--- a/commit.c
+++ b/commit.c
bufptr[47] != '\n')
return error("bad parents in commit %s", sha1_to_hex(item->object.sha1));
bufptr += 48;
- if (graft)
+ /*
+ * The clone is shallow if nr_parent < 0, and we must
+ * not traverse its real parents even when we unhide them.
+ */
+ if (graft && (graft->nr_parent < 0 || grafts_replace_parents))
continue;
new_parent = lookup_commit(parent);
if (new_parent)
diff --git a/environment.c b/environment.c
index 720f26b67d8a7267dbde51a7285bd09d947ac20d..8f5eaa7dd89cbedd5a89e11f0ea24b29701b33c9 100644 (file)
--- a/environment.c
+++ b/environment.c
#define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
#endif
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
+int grafts_replace_parents = 1;
/* Parallel index stat data preload? */
int core_preload_index = 0;
diff --git a/git-repack.sh b/git-repack.sh
index 1bf239499c7bdb04622ea6fa239bd7c0ace42065..1eb3bca352f38ec3807383cc5fff7f7e62731b2b 100755 (executable)
--- a/git-repack.sh
+++ b/git-repack.sh
esac
args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra"
-names=$(git pack-objects --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
+names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
exit 1
if [ -z "$names" ]; then
say Nothing new to pack.
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 87c9b0e121db6c8ab7074e6c4968cd06d37851fe..f4aa0547501a19fe570304e830504ff984f5a9a9 100755 (executable)
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -149,5 +149,17 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar
test_must_fail git show $csha1
'
+test_expect_success 'objects made unreachable by grafts only are kept' '
+ test_tick &&
+ git commit --allow-empty -m "commit 4" &&
+ H0=$(git rev-parse HEAD) &&
+ H1=$(git rev-parse HEAD^) &&
+ H2=$(git rev-parse HEAD^^) &&
+ echo "$H0 $H2" > .git/info/grafts &&
+ git reflog expire --expire=now --expire-unreachable=now --all &&
+ git repack -a -d &&
+ git cat-file -t $H1
+ '
+
test_done