Skip to content

Commit

Permalink
Merge branch 'cc/replace-no-replace'
Browse files Browse the repository at this point in the history
* cc/replace-no-replace:
  git: add --no-replace-objects option to disable replacing
  • Loading branch information
Junio C Hamano committed Oct 19, 2009
2 parents c22e5e9 + b0fa7ab commit 804edc1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
21 changes: 21 additions & 0 deletions Documentation/git-replace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down Expand Up @@ -54,6 +74,7 @@ SEE ALSO
--------
linkgit:git-tag[1]
linkgit:git-branch[1]
linkgit:git[1]

Author
------
Expand Down
6 changes: 5 additions & 1 deletion Documentation/git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -238,6 +238,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
---------------------
Expand Down
4 changes: 3 additions & 1 deletion git.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]";

Expand Down Expand Up @@ -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" );
Expand Down
7 changes: 7 additions & 0 deletions t/t6050-replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 804edc1

Please sign in to comment.