All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] add new GIT_NO_REPLACE_OBJECTS env variable
@ 2009-11-22  6:56 Christian Couder
  2009-11-22  6:56 ` [PATCH v4 1/4] Documentation: fix typos and spelling in git-replace documentation Christian Couder
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christian Couder @ 2009-11-22  6:56 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Michael J Gruber, Jakub Narebski, Johannes Sixt, bill lam,
	Andreas Schwab, Paul Mackerras

Here are all the patches together.

The other change (except putting them together) is that I tried to
improve the commit messages as suggested by Paul and Junio.

The first patch contains documentation fixes and could be applied to
"maint".

Christian Couder (4):
  Documentation: fix typos and spelling in git-replace documentation
  replace: use a GIT_NO_REPLACE_OBJECTS env variable
  gitk: add "--no-replace-objects" option
  Documentation: replace: talk a little bit about
    GIT_NO_REPLACE_OBJECTS

 Documentation/git-replace.txt |   24 ++++++++++++++----------
 cache.h                       |    1 +
 connect.c                     |    1 +
 environment.c                 |    2 ++
 git.c                         |    3 +++
 gitk-git/gitk                 |    5 ++++-
 t/t6050-replace.sh            |   17 +++++++++++++++++
 7 files changed, 42 insertions(+), 11 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 1/4] Documentation: fix typos and spelling in git-replace documentation
  2009-11-22  6:56 [PATCH v4 0/4] add new GIT_NO_REPLACE_OBJECTS env variable Christian Couder
@ 2009-11-22  6:56 ` Christian Couder
  2009-11-22  6:56 ` [PATCH v4 2/4] replace: use a GIT_NO_REPLACE_OBJECTS env variable Christian Couder
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Couder @ 2009-11-22  6:56 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Michael J Gruber, Jakub Narebski, Johannes Sixt, bill lam,
	Andreas Schwab, Paul Mackerras

This patch fix a missing "s" at the end of an occurence of
"--no-replace-objects" and, while at it, it also improves spelling
and rendering of the git-replace man page.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 Documentation/git-replace.txt |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt
index 8adc1ef..69f704f 100644
--- a/Documentation/git-replace.txt
+++ b/Documentation/git-replace.txt
@@ -17,31 +17,32 @@ DESCRIPTION
 Adds a 'replace' reference in `.git/refs/replace/`
 
 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.
 
-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.
 
-Replace references will be used by default by all git commands except
-those doing reachability traversal (prune, pack transfer and fsck).
+Replacement 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".
+It is possible to disable use of replacement references for any
+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
 ------------------------------------------------
 
-show information about commit "bar".
+shows information about commit 'bar'.
 
 OPTIONS
 -------
-- 
1.6.5.1.gaf97d

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v4 2/4] replace: use a GIT_NO_REPLACE_OBJECTS env variable
  2009-11-22  6:56 [PATCH v4 0/4] add new GIT_NO_REPLACE_OBJECTS env variable Christian Couder
  2009-11-22  6:56 ` [PATCH v4 1/4] Documentation: fix typos and spelling in git-replace documentation Christian Couder
@ 2009-11-22  6:56 ` Christian Couder
  2009-11-22  6:56 ` [PATCH v4 3/4] gitk: add "--no-replace-objects" option Christian Couder
  2009-11-22  6:56 ` [PATCH v4 4/4] Documentation: replace: talk a little bit about GIT_NO_REPLACE_OBJECTS Christian Couder
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Couder @ 2009-11-22  6:56 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Michael J Gruber, Jakub Narebski, Johannes Sixt, bill lam,
	Andreas Schwab, Paul Mackerras

Replace refs are useful to change some git objects after they
have started to be shared between different repositories. One
might want to ignore them to see the original state, and
the "--no-replace-objects" option can be used from the command
line to do so.

But the effects of this command line option were not propagated
to git commands called by the original command that was passed
this option.

The goal of this patch is to propagate these effects by using
a new GIT_NO_REPLACE_OBJECTS environment variable.

This environment variable is set when the --no-replace-objects
flag is passed to git, and it is read when other environment
variables are read.

It is useful for example for scripts, as the git commands used in
them can now be aware that they must not read replace refs.

The GIT_NO_REPLACE_OBJECTS is set to "1" instead of "" as it is
safer on some platforms, thanks to Johannes Sixt and Michael J
Gruber.

Tested-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 cache.h            |    1 +
 connect.c          |    1 +
 environment.c      |    2 ++
 git.c              |    3 +++
 t/t6050-replace.sh |   17 +++++++++++++++++
 5 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/cache.h b/cache.h
index 22a06d6..fcdc954 100644
--- a/cache.h
+++ b/cache.h
@@ -374,6 +374,7 @@ static inline enum object_type object_type(unsigned int mode)
 #define CONFIG_ENVIRONMENT "GIT_CONFIG"
 #define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
 #define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES"
+#define NO_REPLACE_OBJECTS_ENVIRONMENT "GIT_NO_REPLACE_OBJECTS"
 #define GITATTRIBUTES_FILE ".gitattributes"
 #define INFOATTRIBUTES_FILE "info/attributes"
 #define ATTRIBUTE_MACRO_PREFIX "[attr]"
diff --git a/connect.c b/connect.c
index 839a103..db965c9 100644
--- a/connect.c
+++ b/connect.c
@@ -609,6 +609,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 			GIT_WORK_TREE_ENVIRONMENT,
 			GRAFT_ENVIRONMENT,
 			INDEX_ENVIRONMENT,
+			NO_REPLACE_OBJECTS_ENVIRONMENT,
 			NULL
 		};
 		conn->env = env;
diff --git a/environment.c b/environment.c
index ed17043..c7ebc54 100644
--- a/environment.c
+++ b/environment.c
@@ -85,6 +85,8 @@ static void setup_git_env(void)
 	git_graft_file = getenv(GRAFT_ENVIRONMENT);
 	if (!git_graft_file)
 		git_graft_file = git_pathdup("info/grafts");
+	if (read_replace_refs && getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
+		read_replace_refs = 0;
 }
 
 int is_bare_repository(void)
diff --git a/git.c b/git.c
index 743ee57..11544cd 100644
--- a/git.c
+++ b/git.c
@@ -89,6 +89,9 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				*envchanged = 1;
 		} else if (!strcmp(cmd, "--no-replace-objects")) {
 			read_replace_refs = 0;
+			setenv(NO_REPLACE_OBJECTS_ENVIRONMENT, "1", 1);
+			if (envchanged)
+				*envchanged = 1;
 		} 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 d4818b4..203ffdb 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -77,6 +77,11 @@ test_expect_success 'test --no-replace-objects option' '
      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
 object $HASH2
 type commit
@@ -202,6 +207,18 @@ test_expect_success 'fetch branch with replacement' '
      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
-- 
1.6.5.1.gaf97d

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v4 3/4] gitk: add "--no-replace-objects" option
  2009-11-22  6:56 [PATCH v4 0/4] add new GIT_NO_REPLACE_OBJECTS env variable Christian Couder
  2009-11-22  6:56 ` [PATCH v4 1/4] Documentation: fix typos and spelling in git-replace documentation Christian Couder
  2009-11-22  6:56 ` [PATCH v4 2/4] replace: use a GIT_NO_REPLACE_OBJECTS env variable Christian Couder
@ 2009-11-22  6:56 ` Christian Couder
  2009-11-22  6:56 ` [PATCH v4 4/4] Documentation: replace: talk a little bit about GIT_NO_REPLACE_OBJECTS Christian Couder
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Couder @ 2009-11-22  6:56 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Michael J Gruber, Jakub Narebski, Johannes Sixt, bill lam,
	Andreas Schwab, Paul Mackerras

Replace refs are useful to change some git objects after they
have started to be shared between different repositories. One
might want to ignore them to see the original state, and
"--no-replace-objects" option can be used from the command
line to do so.

This option simply sets the GIT_NO_REPLACE_OBJECTS environment
variable, and that is enough to make gitk ignore replace refs.

The GIT_NO_REPLACE_OBJECTS is set to "1" instead of "" as it is
safer on some platforms, thanks to Johannes Sixt and Michael J
Gruber.

Tested-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 gitk-git/gitk |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index a0214b7..c586b93 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -128,7 +128,7 @@ proc unmerged_files {files} {
 }
 
 proc parseviewargs {n arglist} {
-    global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs
+    global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
 
     set vdatemode($n) 0
     set vmergeonly($n) 0
@@ -208,6 +208,9 @@ proc parseviewargs {n arglist} {
 		# git rev-parse doesn't understand --merge
 		lappend revargs --gitk-symmetric-diff-marker MERGE_HEAD...HEAD
 	    }
+	    "--no-replace-objects" {
+		set env(GIT_NO_REPLACE_OBJECTS) "1"
+	    }
 	    "-*" {
 		# Other flag arguments including -<n>
 		if {[string is digit -strict [string range $arg 1 end]]} {
-- 
1.6.5.1.gaf97d

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v4 4/4] Documentation: replace: talk a little bit about GIT_NO_REPLACE_OBJECTS
  2009-11-22  6:56 [PATCH v4 0/4] add new GIT_NO_REPLACE_OBJECTS env variable Christian Couder
                   ` (2 preceding siblings ...)
  2009-11-22  6:56 ` [PATCH v4 3/4] gitk: add "--no-replace-objects" option Christian Couder
@ 2009-11-22  6:56 ` Christian Couder
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Couder @ 2009-11-22  6:56 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Michael J Gruber, Jakub Narebski, Johannes Sixt, bill lam,
	Andreas Schwab, Paul Mackerras

It may be useful to know that this environment variable can be used
to prevent commands from using replacement refs.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 Documentation/git-replace.txt |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt
index 69f704f..65a0da5 100644
--- a/Documentation/git-replace.txt
+++ b/Documentation/git-replace.txt
@@ -44,6 +44,9 @@ $ git cat-file commit foo
 
 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
 -------
 -f::
-- 
1.6.5.1.gaf97d

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-11-22  6:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-22  6:56 [PATCH v4 0/4] add new GIT_NO_REPLACE_OBJECTS env variable Christian Couder
2009-11-22  6:56 ` [PATCH v4 1/4] Documentation: fix typos and spelling in git-replace documentation Christian Couder
2009-11-22  6:56 ` [PATCH v4 2/4] replace: use a GIT_NO_REPLACE_OBJECTS env variable Christian Couder
2009-11-22  6:56 ` [PATCH v4 3/4] gitk: add "--no-replace-objects" option Christian Couder
2009-11-22  6:56 ` [PATCH v4 4/4] Documentation: replace: talk a little bit about GIT_NO_REPLACE_OBJECTS Christian Couder

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.