summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cc400f5)
raw | patch | inline | side by side (parent: cc400f5)
author | Christian Couder <chriscool@tuxfamily.org> | |
Fri, 23 Jan 2009 09:07:46 +0000 (10:07 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 1 Jun 2009 00:02:59 +0000 (17:02 -0700) |
This new "read_replace_refs" global variable is set to 1 by
default, so that replace refs are used by default. But
reachability traversal and packing commands ("cmd_fsck",
"cmd_prune", "cmd_pack_objects", "upload_pack",
"cmd_unpack_objects") set it to 0, as they must work with the
original DAG.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
default, so that replace refs are used by default. But
reachability traversal and packing commands ("cmd_fsck",
"cmd_prune", "cmd_pack_objects", "upload_pack",
"cmd_unpack_objects") set it to 0, as they must work with the
original DAG.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/builtin-fsck.c b/builtin-fsck.c
index 7da706cac3bef05f03c09955d41b4e5077558d4f..bc05de6800fe3d6ce9f636404efff553b1dc8f06 100644 (file)
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
struct alternate_object_database *alt;
errors_found = 0;
+ read_replace_refs = 0;
argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0);
if (write_lost_and_found) {
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 9742b45c4da7f9330491d0b4c6d3ed60aadb0f4c..b2c93d3d212055dd097ce696dea8f3beba6afc6a 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
int rp_ac_alloc = 64;
int rp_ac;
+ read_replace_refs = 0;
+
rp_av = xcalloc(rp_ac_alloc, sizeof(*rp_av));
rp_av[0] = "pack-objects";
diff --git a/builtin-prune.c b/builtin-prune.c
index 0ed9cce4a23aa575c1e131a808cedd4f8bb542f4..8459aec8e8ea9d24a13448cf950d2e160361fd9d 100644 (file)
--- a/builtin-prune.c
+++ b/builtin-prune.c
char *s;
save_commit_buffer = 0;
+ read_replace_refs = 0;
init_revisions(&revs, prefix);
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
index 9a773239cabab9998bcea829c0fb2abea9bdb8e8..c9f5ac0c340a700a6ddbe4cd0bf9dd69ee2c5945 100644 (file)
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
int i;
unsigned char sha1[20];
+ read_replace_refs = 0;
+
git_config(git_default_config, NULL);
quiet = !isatty(2);
index 94b12284a265954d55168d33b699c269a4d8b190..91ef34071e7f13b86c14da3c3b64afa488bb9d40 100644 (file)
--- a/cache.h
+++ b/cache.h
extern size_t packed_git_limit;
extern size_t delta_base_cache_limit;
extern int auto_crlf;
+extern int read_replace_refs;
extern int fsync_object_files;
extern int core_preload_index;
diff --git a/environment.c b/environment.c
index 801a005ef1b23ef13cfa9ece676c550fe35dedc0..6d90074648825701eea33a2e9c1436aaff6854d2 100644 (file)
--- a/environment.c
+++ b/environment.c
const char *editor_program;
const char *excludes_file;
int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */
+int read_replace_refs = 1;
enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
diff --git a/replace_object.c b/replace_object.c
index b23e1cd52a455bbe1e55efb589440f1ac3894455..eb59604fd39e2beaf7d43802499c27305ac92132 100644 (file)
--- a/replace_object.c
+++ b/replace_object.c
int pos, depth = MAXREPLACEDEPTH;
const unsigned char *cur = sha1;
+ if (!read_replace_refs)
+ return sha1;
+
prepare_replace_object();
/* Try to recursively replace the object */
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index 334aed621681365725650c9b8e47034fe4e5feb7..17f60632070b5407226421ee8b0315be9d17434b 100755 (executable)
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
git mktag <tag.sig >.git/refs/tags/mytag 2>message
'
+test_expect_success '"git fsck" works' '
+ git fsck master > fsck_master.out &&
+ grep "dangling commit $R" fsck_master.out &&
+ grep "dangling tag $(cat .git/refs/tags/mytag)" fsck_master.out &&
+ test -z "$(git fsck)"
+'
+
+test_expect_success 'repack, clone and fetch work' '
+ git repack -a -d &&
+ git clone --no-hardlinks . clone_dir &&
+ cd clone_dir &&
+ git show HEAD~5 | grep "A U Thor" &&
+ git show $HASH2 | grep "A U Thor" &&
+ git cat-file commit $R &&
+ git repack -a -d &&
+ test_must_fail git cat-file commit $R &&
+ git fetch ../ "refs/replace/*:refs/replace/*" &&
+ git show HEAD~5 | grep "O Thor" &&
+ git show $HASH2 | grep "O Thor" &&
+ git cat-file commit $R &&
+ cd ..
+'
+
#
#
test_done
diff --git a/upload-pack.c b/upload-pack.c
index edc78612289c5bd774e18fe5f8e1b9ea80378a5f..e6c4f347ebf4bbee3bf6826c8089ad81cac15ed6 100644 (file)
--- a/upload-pack.c
+++ b/upload-pack.c
int strict = 0;
git_extract_argv0_path(argv[0]);
+ read_replace_refs = 0;
for (i = 1; i < argc; i++) {
char *arg = argv[i];