diff options
author | Christian Couder <chriscool@tuxfamily.org> | 2009-10-12 22:30:32 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-10-13 01:07:29 -0700 |
commit | b0fa7ab51b29d34579d8f6bb4443dfbcb8278c7a (patch) | |
tree | 3eba2d188f34ca22c2a789f1c4e657139662fcc5 | |
parent | 78d553b7d7b269bb22ebd8b1198657c37484a3a0 (diff) | |
download | git-b0fa7ab51b29d34579d8f6bb4443dfbcb8278c7a.tar.gz git-b0fa7ab51b29d34579d8f6bb4443dfbcb8278c7a.tar.xz |
git: add --no-replace-objects option to disable replacing
Commit dae556b (environment: add global variable to disable replacement)
adds a variable to enable/disable replacement, and it is enabled by
default for most commands.
So there is no way to disable it for some commands, which is annoying
when we want to get information about a commit that has been replaced.
For example:
$ git cat-file -p N
would output information about the replacement commit if commit N is
replaced.
With the "--no-replace-objects" option that this patch adds it is
possible to get information about the original commit using:
$ git --no-replace-objects cat-file -p N
While at it, let's add some documentation about this new option in the
"git replace" man page too.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | Documentation/git-replace.txt | 21 | ||||
-rw-r--r-- | Documentation/git.txt | 6 | ||||
-rw-r--r-- | git.c | 4 | ||||
-rwxr-xr-x | t/t6050-replace.sh | 7 |
4 files changed, 36 insertions, 2 deletions
diff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt index 915cb77b2..8adc1ef55 100644 --- a/Documentation/git-replace.txt +++ b/Documentation/git-replace.txt @@ -23,6 +23,26 @@ replacement object. Unless `-f` is given, the replace reference must not yet exist in `.git/refs/replace/` directory. +Replace references will be used by default by all git commands except +those doing reachability traversal (prune, pack transfer and fsck). + +It is possible to disable use of replacement refs for any command +using the --no-replace-objects option just after "git". + +For example if commit "foo" has been replaced by commit "bar": + +------------------------------------------------ +$ git --no-replace-object cat-file commit foo +------------------------------------------------ + +show information about commit "foo", while: + +------------------------------------------------ +$ git cat-file commit foo +------------------------------------------------ + +show information about commit "bar". + OPTIONS ------- -f:: @@ -54,6 +74,7 @@ SEE ALSO -------- linkgit:git-tag[1] linkgit:git-branch[1] +linkgit:git[1] Author ------ diff --git a/Documentation/git.txt b/Documentation/git.txt index d97aaf5bf..2f4541780 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path] - [-p|--paginate|--no-pager] + [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS] @@ -237,6 +237,10 @@ help ...`. environment is not set, it is set to the current working directory. +--no-replace-objects:: + Do not use replacement refs to replace git objects. See + linkgit:git-replace[1] for more information. + FURTHER DOCUMENTATION --------------------- @@ -6,7 +6,7 @@ const char git_usage_string[] = "git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]\n" - " [-p|--paginate|--no-pager]\n" + " [-p|--paginate|--no-pager] [--no-replace-objects]\n" " [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]\n" " [--help] COMMAND [ARGS]"; @@ -87,6 +87,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) use_pager = 0; if (envchanged) *envchanged = 1; + } else if (!strcmp(cmd, "--no-replace-objects")) { + read_replace_refs = 0; } else if (!strcmp(cmd, "--git-dir")) { if (*argc < 2) { fprintf(stderr, "No directory given for --git-dir.\n" ); diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh index 8b8bd81c0..d4818b430 100755 --- a/t/t6050-replace.sh +++ b/t/t6050-replace.sh @@ -70,6 +70,13 @@ test_expect_success 'replace the author' ' git show $HASH2 | grep "O Thor" ' +test_expect_success 'test --no-replace-objects option' ' + git cat-file commit $HASH2 | grep "author O Thor" && + git --no-replace-objects cat-file commit $HASH2 | grep "author A U Thor" && + git show $HASH2 | grep "O Thor" && + git --no-replace-objects show $HASH2 | grep "A U Thor" +' + cat >tag.sig <<EOF object $HASH2 type commit |