Merge branch 'cc/replace'
* cc/replace: Documentation: talk a little bit about GIT_NO_REPLACE_OBJECTS Documentation: fix typos and spelling in replace documentation replace: use a GIT_NO_REPLACE_OBJECTS env variable
This commit is contained in:
@ -17,31 +17,35 @@ DESCRIPTION
|
|||||||
Adds a 'replace' reference in `.git/refs/replace/`
|
Adds a 'replace' reference in `.git/refs/replace/`
|
||||||
|
|
||||||
The name of the 'replace' reference is the SHA1 of the object that is
|
The name of the 'replace' reference is the SHA1 of the object that is
|
||||||
replaced. The content of the replace reference is the SHA1 of the
|
replaced. The content of the 'replace' reference is the SHA1 of the
|
||||||
replacement object.
|
replacement object.
|
||||||
|
|
||||||
Unless `-f` is given, the replace reference must not yet exist in
|
Unless `-f` is given, the 'replace' reference must not yet exist in
|
||||||
`.git/refs/replace/` directory.
|
`.git/refs/replace/` directory.
|
||||||
|
|
||||||
Replace references will be used by default by all git commands except
|
Replacement references will be used by default by all git commands
|
||||||
those doing reachability traversal (prune, pack transfer and fsck).
|
except those doing reachability traversal (prune, pack transfer and
|
||||||
|
fsck).
|
||||||
|
|
||||||
It is possible to disable use of replacement refs for any command
|
It is possible to disable use of replacement references for any
|
||||||
using the --no-replace-objects option just after "git".
|
command using the `--no-replace-objects` option just after 'git'.
|
||||||
|
|
||||||
For example if commit "foo" has been replaced by commit "bar":
|
For example if commit 'foo' has been replaced by commit 'bar':
|
||||||
|
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
$ git --no-replace-object cat-file commit foo
|
$ git --no-replace-objects cat-file commit foo
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
show information about commit "foo", while:
|
shows information about commit 'foo', while:
|
||||||
|
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
$ git cat-file commit foo
|
$ git cat-file commit foo
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
show information about commit "bar".
|
shows information about commit 'bar'.
|
||||||
|
|
||||||
|
The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to
|
||||||
|
achieve the same effect as the `--no-replace-objects` option.
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-------
|
-------
|
||||||
|
1
cache.h
1
cache.h
@ -369,6 +369,7 @@ static inline enum object_type object_type(unsigned int mode)
|
|||||||
#define CONFIG_ENVIRONMENT "GIT_CONFIG"
|
#define CONFIG_ENVIRONMENT "GIT_CONFIG"
|
||||||
#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
|
#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
|
||||||
#define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES"
|
#define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES"
|
||||||
|
#define NO_REPLACE_OBJECTS_ENVIRONMENT "GIT_NO_REPLACE_OBJECTS"
|
||||||
#define GITATTRIBUTES_FILE ".gitattributes"
|
#define GITATTRIBUTES_FILE ".gitattributes"
|
||||||
#define INFOATTRIBUTES_FILE "info/attributes"
|
#define INFOATTRIBUTES_FILE "info/attributes"
|
||||||
#define ATTRIBUTE_MACRO_PREFIX "[attr]"
|
#define ATTRIBUTE_MACRO_PREFIX "[attr]"
|
||||||
|
@ -609,6 +609,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
|
|||||||
GIT_WORK_TREE_ENVIRONMENT,
|
GIT_WORK_TREE_ENVIRONMENT,
|
||||||
GRAFT_ENVIRONMENT,
|
GRAFT_ENVIRONMENT,
|
||||||
INDEX_ENVIRONMENT,
|
INDEX_ENVIRONMENT,
|
||||||
|
NO_REPLACE_OBJECTS_ENVIRONMENT,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
conn->env = env;
|
conn->env = env;
|
||||||
|
@ -84,6 +84,8 @@ static void setup_git_env(void)
|
|||||||
git_graft_file = getenv(GRAFT_ENVIRONMENT);
|
git_graft_file = getenv(GRAFT_ENVIRONMENT);
|
||||||
if (!git_graft_file)
|
if (!git_graft_file)
|
||||||
git_graft_file = git_pathdup("info/grafts");
|
git_graft_file = git_pathdup("info/grafts");
|
||||||
|
if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
|
||||||
|
read_replace_refs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_bare_repository(void)
|
int is_bare_repository(void)
|
||||||
|
3
git.c
3
git.c
@ -89,6 +89,9 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
|
|||||||
*envchanged = 1;
|
*envchanged = 1;
|
||||||
} else if (!strcmp(cmd, "--no-replace-objects")) {
|
} else if (!strcmp(cmd, "--no-replace-objects")) {
|
||||||
read_replace_refs = 0;
|
read_replace_refs = 0;
|
||||||
|
setenv(NO_REPLACE_OBJECTS_ENVIRONMENT, "1", 1);
|
||||||
|
if (envchanged)
|
||||||
|
*envchanged = 1;
|
||||||
} else if (!strcmp(cmd, "--git-dir")) {
|
} else if (!strcmp(cmd, "--git-dir")) {
|
||||||
if (*argc < 2) {
|
if (*argc < 2) {
|
||||||
fprintf(stderr, "No directory given for --git-dir.\n" );
|
fprintf(stderr, "No directory given for --git-dir.\n" );
|
||||||
|
@ -77,6 +77,11 @@ test_expect_success 'test --no-replace-objects option' '
|
|||||||
git --no-replace-objects show $HASH2 | grep "A U Thor"
|
git --no-replace-objects show $HASH2 | grep "A U Thor"
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '
|
||||||
|
GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep "author A U Thor" &&
|
||||||
|
GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep "A U Thor"
|
||||||
|
'
|
||||||
|
|
||||||
cat >tag.sig <<EOF
|
cat >tag.sig <<EOF
|
||||||
object $HASH2
|
object $HASH2
|
||||||
type commit
|
type commit
|
||||||
@ -202,6 +207,18 @@ test_expect_success 'fetch branch with replacement' '
|
|||||||
cd ..
|
cd ..
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'bisect and replacements' '
|
||||||
|
git bisect start $HASH7 $HASH1 &&
|
||||||
|
test "$S" = "$(git rev-parse --verify HEAD)" &&
|
||||||
|
git bisect reset &&
|
||||||
|
GIT_NO_REPLACE_OBJECTS=1 git bisect start $HASH7 $HASH1 &&
|
||||||
|
test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
|
||||||
|
git bisect reset &&
|
||||||
|
git --no-replace-objects bisect start $HASH7 $HASH1 &&
|
||||||
|
test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
|
||||||
|
git bisect reset
|
||||||
|
'
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
test_done
|
test_done
|
||||||
|
Reference in New Issue
Block a user