Skip to content

Commit 804edc1

Browse files
committed
Merge branch 'cc/replace-no-replace'
* cc/replace-no-replace: git: add --no-replace-objects option to disable replacing
2 parents c22e5e9 + b0fa7ab commit 804edc1

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

Documentation/git-replace.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@ replacement object.
2323
Unless `-f` is given, the replace reference must not yet exist in
2424
`.git/refs/replace/` directory.
2525

26+
Replace references will be used by default by all git commands except
27+
those doing reachability traversal (prune, pack transfer and fsck).
28+
29+
It is possible to disable use of replacement refs for any command
30+
using the --no-replace-objects option just after "git".
31+
32+
For example if commit "foo" has been replaced by commit "bar":
33+
34+
------------------------------------------------
35+
$ git --no-replace-object cat-file commit foo
36+
------------------------------------------------
37+
38+
show information about commit "foo", while:
39+
40+
------------------------------------------------
41+
$ git cat-file commit foo
42+
------------------------------------------------
43+
44+
show information about commit "bar".
45+
2646
OPTIONS
2747
-------
2848
-f::
@@ -54,6 +74,7 @@ SEE ALSO
5474
--------
5575
linkgit:git-tag[1]
5676
linkgit:git-branch[1]
77+
linkgit:git[1]
5778

5879
Author
5980
------

Documentation/git.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SYNOPSIS
1010
--------
1111
[verse]
1212
'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]
13-
[-p|--paginate|--no-pager]
13+
[-p|--paginate|--no-pager] [--no-replace-objects]
1414
[--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
1515
[--help] COMMAND [ARGS]
1616

@@ -238,6 +238,10 @@ help ...`.
238238
environment is not set, it is set to the current working
239239
directory.
240240

241+
--no-replace-objects::
242+
Do not use replacement refs to replace git objects. See
243+
linkgit:git-replace[1] for more information.
244+
241245

242246
FURTHER DOCUMENTATION
243247
---------------------

git.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
const char git_usage_string[] =
88
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]\n"
9-
" [-p|--paginate|--no-pager]\n"
9+
" [-p|--paginate|--no-pager] [--no-replace-objects]\n"
1010
" [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]\n"
1111
" [--help] COMMAND [ARGS]";
1212

@@ -87,6 +87,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
8787
use_pager = 0;
8888
if (envchanged)
8989
*envchanged = 1;
90+
} else if (!strcmp(cmd, "--no-replace-objects")) {
91+
read_replace_refs = 0;
9092
} else if (!strcmp(cmd, "--git-dir")) {
9193
if (*argc < 2) {
9294
fprintf(stderr, "No directory given for --git-dir.\n" );

t/t6050-replace.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ test_expect_success 'replace the author' '
7070
git show $HASH2 | grep "O Thor"
7171
'
7272

73+
test_expect_success 'test --no-replace-objects option' '
74+
git cat-file commit $HASH2 | grep "author O Thor" &&
75+
git --no-replace-objects cat-file commit $HASH2 | grep "author A U Thor" &&
76+
git show $HASH2 | grep "O Thor" &&
77+
git --no-replace-objects show $HASH2 | grep "A U Thor"
78+
'
79+
7380
cat >tag.sig <<EOF
7481
object $HASH2
7582
type commit

0 commit comments

Comments
 (0)