git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ann T Ropea <bedhanger@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Philip Oakley <philipoakley@iee.org>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Git Mailing List <git@vger.kernel.org>,
	Daniel Barkalow <barkalow@iabervon.org>,
	Ann T Ropea <bedhanger@gmx.de>
Subject: Re: [PATCH v5 3/7] print_sha1_ellipsis: introduce helper
Date: Sun,  3 Dec 2017 22:27:39 +0100	[thread overview]
Message-ID: <20171203212743.10228-3-bedhanger@gmx.de> (raw)
In-Reply-To: <20171203212743.10228-1-bedhanger@gmx.de>
In-Reply-To: <xmqqd145k9td.fsf@gitster.mtv.corp.google.com>

Introduce a helper print_sha1_ellipsis() that pays attention to the
GIT_PRINT_SHA1_ELLIPSIS environment variable, and prepare the tests to
unconditionally set it for the test pieces that will be broken once the code
stops showing the extra dots by default.

The removal of these dots is merely a plan at this step and has not happened
yet but soon will.

Document GIT_PRINT_SHA1_ELLIPSIS.

Signed-off-by: Ann T Ropea <bedhanger@gmx.de>
---
v2: rename patch series & focus on removal of ellipses
v3: env var instead of config option, use one-line comments where appropriate, preserve indent level
v4: improve env var handling (rename, helper func to query, docu)
v5: rewrite series to take Junio's comments in <xmqqd145k9td.fsf@gitster.mtv.corp.google.com> aboard
 Documentation/git.txt        |  9 +++++++++
 cache.h                      |  6 ++++++
 environment.c                | 15 +++++++++++++++
 t/t3040-subprojects-basic.sh |  2 +-
 t/t4013-diff-various.sh      |  2 +-
 t/t9300-fast-import.sh       |  2 +-
 6 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index 483a1f35475e..395c88c8a31f 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -731,6 +731,15 @@ corresponding standard handle, and if `GIT_REDIRECT_STDERR` is
 `2>&1`, standard error will be redirected to the same handle as
 standard output.
 
+`GIT_PRINT_SHA1_ELLIPSIS` (deprecated)::
+	If set to `yes`, print an ellipsis following an
+	(abbreviated) SHA-1 value.  This affects indications of
+	detached HEADs (linkgit:git-checkout[1]) and the raw
+	diff output (linkgit:git-diff[1]).  Printing an
+	ellipsis in the cases mentioned is no longer considered
+	adequate and support for it is likely to be removed in the
+	foreseeable future (along with the variable).
+
 Discussion[[Discussion]]
 ------------------------
 
diff --git a/cache.h b/cache.h
index 2e143450514c..dc30f6b92025 100644
--- a/cache.h
+++ b/cache.h
@@ -1958,4 +1958,10 @@ void sleep_millisec(int millisec);
  */
 void safe_create_dir(const char *dir, int share);
 
+/*
+ * Should we print an ellipsis after an abbreviated SHA-1 value
+ * when doing diff-raw output or indicating a detached HEAD?
+ */
+extern int print_sha1_ellipsis(void);
+
 #endif /* CACHE_H */
diff --git a/environment.c b/environment.c
index 8fa032f30742..63ac38a46f8f 100644
--- a/environment.c
+++ b/environment.c
@@ -344,3 +344,18 @@ int use_optional_locks(void)
 {
 	return git_env_bool(GIT_OPTIONAL_LOCKS_ENVIRONMENT, 1);
 }
+
+int print_sha1_ellipsis(void)
+{
+	/*
+	 * Determine if the calling environment contains the variable
+	 * GIT_PRINT_SHA1_ELLIPSIS set to "yes".
+	 */
+	static int cached_result = -1; /* unknown */
+
+	if (cached_result < 0) {
+		const char *v = getenv("GIT_PRINT_SHA1_ELLIPSIS");
+		cached_result = (v && !strcasecmp(v, "yes"));
+	}
+	return cached_result;
+}
diff --git a/t/t3040-subprojects-basic.sh b/t/t3040-subprojects-basic.sh
index 0a4ff6d824a0..b81eb5fd6ffa 100755
--- a/t/t3040-subprojects-basic.sh
+++ b/t/t3040-subprojects-basic.sh
@@ -19,7 +19,7 @@ test_expect_success 'setup: create subprojects' '
 	git update-index --add sub1 &&
 	git add sub2 &&
 	git commit -q -m "subprojects added" &&
-	git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
+	GIT_PRINT_SHA1_ELLIPSIS="yes" git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
 	git branch save HEAD &&
 	cat >expected <<-\EOF &&
 	:000000 160000 00000... A	sub1
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index c515e3e53fee..9bed64d53e01 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -131,7 +131,7 @@ do
 	test_expect_success "git $cmd" '
 		{
 			echo "\$ git $cmd"
-			git $cmd |
+			GIT_PRINT_SHA1_ELLIPSIS="yes" git $cmd |
 			sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
 			    -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
 			echo "\$"
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index d47560b6343d..e4d06accc458 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -876,7 +876,7 @@ test_expect_success 'L: verify internal tree sorting' '
 	EXPECT_END
 
 	git fast-import <input &&
-	git diff-tree --abbrev --raw L^ L >output &&
+	GIT_PRINT_SHA1_ELLIPSIS="yes" git diff-tree --abbrev --raw L^ L >output &&
 	test_cmp expect output
 '
 
-- 
2.13.6


  parent reply	other threads:[~2017-12-03 21:29 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-05 16:27 [PATCH 1/3] checkout: describe_detached_head: remove 3dots after committish Ann T Ropea
2017-11-05 16:27 ` [PATCH 2/3] Documentation: user-manual: limit potentially confusing usage of 3dots (and 2dots) Ann T Ropea
2017-11-05 16:27 ` [PATCH 3/3] Documentation: revisions: add note about 3dots usages as continuation indications Ann T Ropea
2017-11-06  4:34   ` Junio C Hamano
2017-11-06  2:45 ` [PATCH 1/3] checkout: describe_detached_head: remove 3dots after committish Junio C Hamano
2017-11-07  0:30   ` Philip Oakley
2017-11-07  0:52 ` Junio C Hamano
2017-11-07  2:53 ` Ann T Ropea
2017-11-07 23:25   ` Philip Oakley
2017-11-08  1:59     ` Junio C Hamano
2017-11-09 23:15       ` Philip Oakley
2017-11-13 22:36         ` [PATCH v2 1/6] config: introduce core.printsha1ellipsis Ann T Ropea
2017-11-13 22:36         ` [PATCH v2 2/6] checkout: describe_detached_head: remove ellipsis after committish Ann T Ropea
2017-11-13 22:36         ` [PATCH v2 3/6] diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value Ann T Ropea
2017-11-14  3:08           ` Junio C Hamano
2017-11-19 17:38             ` Ann T Ropea
2017-11-20  1:48               ` Junio C Hamano
2017-11-19 18:41             ` [PATCH v3 1/5] checkout: describe_detached_head: remove ellipsis after committish Ann T Ropea
2017-11-20  3:35               ` Junio C Hamano
2017-11-19 18:41             ` [PATCH v3 2/5] diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value Ann T Ropea
2017-11-19 19:11               ` Eric Sunshine
2017-11-19 18:41             ` [PATCH v3 3/5] Documentation: user-manual: limit usage of ellipsis Ann T Ropea
2017-11-19 19:15               ` Eric Sunshine
2017-11-24 23:53                 ` [PATCH v4 1/6] diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value Ann T Ropea
2017-11-25  5:01                   ` Junio C Hamano
2017-11-26  3:17                     ` Junio C Hamano
2017-11-26  3:19                       ` Junio C Hamano
2017-11-26  3:25                       ` Junio C Hamano
2017-12-03 21:27                       ` [PATCH v5 1/7] Documentation: revisions: fix typo: "three dot" ---> "three-dot" (in line with "two-dot") Ann T Ropea
2017-12-04 16:52                         ` Junio C Hamano
2017-12-03 21:27                       ` [PATCH v5 2/7] Documentation: user-manual: limit usage of ellipsis Ann T Ropea
2017-12-03 21:27                       ` Ann T Ropea [this message]
2017-12-03 21:27                       ` [PATCH v5 4/7] checkout: describe_detached_head: remove ellipsis after committish Ann T Ropea
2017-12-04 16:46                         ` Junio C Hamano
2017-12-04 23:13                           ` [PATCH v6 " Ann T Ropea
2017-12-05 16:03                             ` Junio C Hamano
2017-12-06  0:20                               ` [PATCH v7 " Ann T Ropea
2017-12-06 16:47                                 ` Junio C Hamano
2017-12-06 22:02                                   ` Ann T Ropea
2017-12-03 21:27                       ` [PATCH v5 5/7] t4013: prepare for upcoming "diff --raw --abbrev" output format change Ann T Ropea
2017-12-03 21:27                       ` [PATCH v5 6/7] diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value Ann T Ropea
2017-12-03 21:27                       ` [PATCH v5 7/7] t4013: test new output from diff --abbrev --raw Ann T Ropea
2017-11-24 23:53                 ` [PATCH v4 2/6] checkout: describe_detached_head: remove ellipsis after committish Ann T Ropea
2017-11-24 23:53                 ` [PATCH v4 3/6] Documentation: user-manual: limit usage of ellipsis Ann T Ropea
2017-11-24 23:53                 ` [PATCH v4 4/6] Documentation: revisions: fix typo: "three dot" ---> "three-dot" (in line with "two-dot") Ann T Ropea
2017-11-24 23:53                 ` [PATCH v4 5/6] Documentation: git: document GIT_PRINT_SHA1_ELLIPSIS Ann T Ropea
2017-11-24 23:53                 ` [PATCH v4 6/6] Testing: provide existing tests requiring them with ellipses after SHA-1 values Ann T Ropea
2017-11-19 18:41             ` [PATCH v3 4/5] Documentation: revisions: fix typo: "three dot" ---> "three-dot" (in line with "two-dot") Ann T Ropea
2017-11-19 18:41             ` [PATCH v3 5/5] Testing: provide tests requiring them with ellipses after SHA-1 values Ann T Ropea
2017-11-20  4:06               ` Junio C Hamano
2017-11-20 12:25                 ` Philip Oakley
2017-11-22  5:53                   ` Junio C Hamano
2017-11-22 23:41                     ` Philip Oakley
2017-11-24  0:40                       ` Junio C Hamano
2017-11-13 22:36         ` [PATCH v2 4/6] Documentation: user-manual: limit usage of ellipsis Ann T Ropea
2017-11-13 22:36         ` [PATCH v2 5/6] Documentation: revisions: fix typo: "three dot" ---> "three-dot" (in line with "two-dot") Ann T Ropea
2017-11-13 22:36         ` [PATCH v2 6/6] Testing: provide tests requiring them with ellipses after SHA-1 values Ann T Ropea
2017-11-14  3:20           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171203212743.10228-3-bedhanger@gmx.de \
    --to=bedhanger@gmx.de \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=philipoakley@iee.org \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).