{"thread":{"id":"21700","subject":"[PATCH v4 0/4] add new GIT_NO_REPLACE_OBJECTS env variable","startedAt":"2009-11-22T06:56:40Z","lastAt":"2009-11-22T06:56:44Z","messageCount":5,"participants":["Christian Couder"],"isPatch":true,"patchVersion":4,"patchTotal":4},"messages":[{"id":"128093","messageId":"20091122064652.4811.38993.chriscool@tuxfamily.org","threadId":"21700","inReplyTo":null,"subject":"[PATCH v4 0/4] add new GIT_NO_REPLACE_OBJECTS env variable","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-11-22T06:56:40Z","receivedAt":"2009-11-22T06:56:40Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Here are all the patches together.\n\nThe other change (except putting them together) is that I tried to\nimprove the commit messages as suggested by Paul and Junio.\n\nThe first patch contains documentation fixes and could be applied to\n\"maint\".\n\nChristian Couder (4):\n  Documentation: fix typos and spelling in git-replace documentation\n  replace: use a GIT_NO_REPLACE_OBJECTS env variable\n  gitk: add \"--no-replace-objects\" option\n  Documentation: replace: talk a little bit about\n    GIT_NO_REPLACE_OBJECTS\n\n Documentation/git-replace.txt |   24 ++++++++++++++----------\n cache.h                       |    1 +\n connect.c                     |    1 +\n environment.c                 |    2 ++\n git.c                         |    3 +++\n gitk-git/gitk                 |    5 ++++-\n t/t6050-replace.sh            |   17 +++++++++++++++++\n 7 files changed, 42 insertions(+), 11 deletions(-)\n"},{"id":"128094","messageId":"20091122065645.4811.96823.chriscool@tuxfamily.org","threadId":"21700","inReplyTo":"20091122064652.4811.38993.chriscool@tuxfamily.org","subject":"[PATCH v4 1/4] Documentation: fix typos and spelling in git-replace documentation","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-11-22T06:56:41Z","receivedAt":"2009-11-22T06:56:41Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This patch fix a missing \"s\" at the end of an occurence of\n\"--no-replace-objects\" and, while at it, it also improves spelling\nand rendering of the git-replace man page.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n Documentation/git-replace.txt |   21 +++++++++++----------\n 1 files changed, 11 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt\nindex 8adc1ef..69f704f 100644\n--- a/Documentation/git-replace.txt\n+++ b/Documentation/git-replace.txt\n@@ -17,31 +17,32 @@ DESCRIPTION\n Adds a 'replace' reference in `.git/refs/replace/`\n \n The name of the 'replace' reference is the SHA1 of the object that is\n-replaced. The content of the replace reference is the SHA1 of the\n+replaced. The content of the 'replace' reference is the SHA1 of the\n replacement object.\n \n-Unless `-f` is given, the replace reference must not yet exist in\n+Unless `-f` is given, the 'replace' reference must not yet exist in\n `.git/refs/replace/` directory.\n \n-Replace references will be used by default by all git commands except\n-those doing reachability traversal (prune, pack transfer and fsck).\n+Replacement references will be used by default by all git commands\n+except those doing reachability traversal (prune, pack transfer and\n+fsck).\n \n-It is possible to disable use of replacement refs for any command\n-using the --no-replace-objects option just after \"git\".\n+It is possible to disable use of replacement references for any\n+command using the `--no-replace-objects` option just after 'git'.\n \n-For example if commit \"foo\" has been replaced by commit \"bar\":\n+For example if commit 'foo' has been replaced by commit 'bar':\n \n ------------------------------------------------\n-$ git --no-replace-object cat-file commit foo\n+$ git --no-replace-objects cat-file commit foo\n ------------------------------------------------\n \n-show information about commit \"foo\", while:\n+shows information about commit 'foo', while:\n \n ------------------------------------------------\n $ git cat-file commit foo\n ------------------------------------------------\n \n-show information about commit \"bar\".\n+shows information about commit 'bar'.\n \n OPTIONS\n -------\n-- \n1.6.5.1.gaf97d\n"},{"id":"128096","messageId":"20091122065645.4811.9133.chriscool@tuxfamily.org","threadId":"21700","inReplyTo":"20091122064652.4811.38993.chriscool@tuxfamily.org","subject":"[PATCH v4 2/4] replace: use a GIT_NO_REPLACE_OBJECTS env variable","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-11-22T06:56:42Z","receivedAt":"2009-11-22T06:56:42Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Replace refs are useful to change some git objects after they\nhave started to be shared between different repositories. One\nmight want to ignore them to see the original state, and\nthe \"--no-replace-objects\" option can be used from the command\nline to do so.\n\nBut the effects of this command line option were not propagated\nto git commands called by the original command that was passed\nthis option.\n\nThe goal of this patch is to propagate these effects by using\na new GIT_NO_REPLACE_OBJECTS environment variable.\n\nThis environment variable is set when the --no-replace-objects\nflag is passed to git, and it is read when other environment\nvariables are read.\n\nIt is useful for example for scripts, as the git commands used in\nthem can now be aware that they must not read replace refs.\n\nThe GIT_NO_REPLACE_OBJECTS is set to \"1\" instead of \"\" as it is\nsafer on some platforms, thanks to Johannes Sixt and Michael J\nGruber.\n\nTested-by: Michael J Gruber <git@drmicha.warpmail.net>\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n cache.h            |    1 +\n connect.c          |    1 +\n environment.c      |    2 ++\n git.c              |    3 +++\n t/t6050-replace.sh |   17 +++++++++++++++++\n 5 files changed, 24 insertions(+), 0 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 22a06d6..fcdc954 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -374,6 +374,7 @@ static inline enum object_type object_type(unsigned int mode)\n #define CONFIG_ENVIRONMENT \"GIT_CONFIG\"\n #define EXEC_PATH_ENVIRONMENT \"GIT_EXEC_PATH\"\n #define CEILING_DIRECTORIES_ENVIRONMENT \"GIT_CEILING_DIRECTORIES\"\n+#define NO_REPLACE_OBJECTS_ENVIRONMENT \"GIT_NO_REPLACE_OBJECTS\"\n #define GITATTRIBUTES_FILE \".gitattributes\"\n #define INFOATTRIBUTES_FILE \"info/attributes\"\n #define ATTRIBUTE_MACRO_PREFIX \"[attr]\"\ndiff --git a/connect.c b/connect.c\nindex 839a103..db965c9 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -609,6 +609,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,\n \t\t\tGIT_WORK_TREE_ENVIRONMENT,\n \t\t\tGRAFT_ENVIRONMENT,\n \t\t\tINDEX_ENVIRONMENT,\n+\t\t\tNO_REPLACE_OBJECTS_ENVIRONMENT,\n \t\t\tNULL\n \t\t};\n \t\tconn->env = env;\ndiff --git a/environment.c b/environment.c\nindex ed17043..c7ebc54 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -85,6 +85,8 @@ static void setup_git_env(void)\n \tgit_graft_file = getenv(GRAFT_ENVIRONMENT);\n \tif (!git_graft_file)\n \t\tgit_graft_file = git_pathdup(\"info/grafts\");\n+\tif (read_replace_refs && getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))\n+\t\tread_replace_refs = 0;\n }\n \n int is_bare_repository(void)\ndiff --git a/git.c b/git.c\nindex 743ee57..11544cd 100644\n--- a/git.c\n+++ b/git.c\n@@ -89,6 +89,9 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t\t\t*envchanged = 1;\n \t\t} else if (!strcmp(cmd, \"--no-replace-objects\")) {\n \t\t\tread_replace_refs = 0;\n+\t\t\tsetenv(NO_REPLACE_OBJECTS_ENVIRONMENT, \"1\", 1);\n+\t\t\tif (envchanged)\n+\t\t\t\t*envchanged = 1;\n \t\t} else if (!strcmp(cmd, \"--git-dir\")) {\n \t\t\tif (*argc < 2) {\n \t\t\t\tfprintf(stderr, \"No directory given for --git-dir.\\n\" );\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex d4818b4..203ffdb 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -77,6 +77,11 @@ test_expect_success 'test --no-replace-objects option' '\n      git --no-replace-objects show $HASH2 | grep \"A U Thor\"\n '\n \n+test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n+     GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n+     GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n+'\n+\n cat >tag.sig <<EOF\n object $HASH2\n type commit\n@@ -202,6 +207,18 @@ test_expect_success 'fetch branch with replacement' '\n      cd ..\n '\n \n+test_expect_success 'bisect and replacements' '\n+     git bisect start $HASH7 $HASH1 &&\n+     test \"$S\" = \"$(git rev-parse --verify HEAD)\" &&\n+     git bisect reset &&\n+     GIT_NO_REPLACE_OBJECTS=1 git bisect start $HASH7 $HASH1 &&\n+     test \"$HASH4\" = \"$(git rev-parse --verify HEAD)\" &&\n+     git bisect reset &&\n+     git --no-replace-objects bisect start $HASH7 $HASH1 &&\n+     test \"$HASH4\" = \"$(git rev-parse --verify HEAD)\" &&\n+     git bisect reset\n+'\n+\n #\n #\n test_done\n-- \n1.6.5.1.gaf97d\n"},{"id":"128097","messageId":"20091122065645.4811.99983.chriscool@tuxfamily.org","threadId":"21700","inReplyTo":"20091122064652.4811.38993.chriscool@tuxfamily.org","subject":"[PATCH v4 3/4] gitk: add \"--no-replace-objects\" option","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-11-22T06:56:43Z","receivedAt":"2009-11-22T06:56:43Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Replace refs are useful to change some git objects after they\nhave started to be shared between different repositories. One\nmight want to ignore them to see the original state, and\n\"--no-replace-objects\" option can be used from the command\nline to do so.\n\nThis option simply sets the GIT_NO_REPLACE_OBJECTS environment\nvariable, and that is enough to make gitk ignore replace refs.\n\nThe GIT_NO_REPLACE_OBJECTS is set to \"1\" instead of \"\" as it is\nsafer on some platforms, thanks to Johannes Sixt and Michael J\nGruber.\n\nTested-by: Michael J Gruber <git@drmicha.warpmail.net>\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n gitk-git/gitk |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex a0214b7..c586b93 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -128,7 +128,7 @@ proc unmerged_files {files} {\n }\n \n proc parseviewargs {n arglist} {\n-    global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs\n+    global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env\n \n     set vdatemode($n) 0\n     set vmergeonly($n) 0\n@@ -208,6 +208,9 @@ proc parseviewargs {n arglist} {\n \t\t# git rev-parse doesn't understand --merge\n \t\tlappend revargs --gitk-symmetric-diff-marker MERGE_HEAD...HEAD\n \t    }\n+\t    \"--no-replace-objects\" {\n+\t\tset env(GIT_NO_REPLACE_OBJECTS) \"1\"\n+\t    }\n \t    \"-*\" {\n \t\t# Other flag arguments including -<n>\n \t\tif {[string is digit -strict [string range $arg 1 end]]} {\n-- \n1.6.5.1.gaf97d\n"},{"id":"128095","messageId":"20091122065645.4811.8117.chriscool@tuxfamily.org","threadId":"21700","inReplyTo":"20091122064652.4811.38993.chriscool@tuxfamily.org","subject":"[PATCH v4 4/4] Documentation: replace: talk a little bit about GIT_NO_REPLACE_OBJECTS","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-11-22T06:56:44Z","receivedAt":"2009-11-22T06:56:44Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"It may be useful to know that this environment variable can be used\nto prevent commands from using replacement refs.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n Documentation/git-replace.txt |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt\nindex 69f704f..65a0da5 100644\n--- a/Documentation/git-replace.txt\n+++ b/Documentation/git-replace.txt\n@@ -44,6 +44,9 @@ $ git cat-file commit foo\n \n shows information about commit 'bar'.\n \n+The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to\n+achieve the same effect as the `--no-replace-objects` option.\n+\n OPTIONS\n -------\n -f::\n-- \n1.6.5.1.gaf97d\n"}]}