summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnn T Ropea <bedhanger@gmx.de>2017-12-03 21:27:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-12-04 16:25:35 (GMT)
commita2cd709de314a7bfa038e14fd36f1d21077b4173 (patch)
tree49da7a18df71cc8cf4f3e6d1a05e44c1b654717a
parentf61d89e1009da8025794057ca87c21e277d380fa (diff)
downloadgit-a2cd709de314a7bfa038e14fd36f1d21077b4173.zip
git-a2cd709de314a7bfa038e14fd36f1d21077b4173.tar.gz
git-a2cd709de314a7bfa038e14fd36f1d21077b4173.tar.bz2
print_sha1_ellipsis: introduce helper
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Documentation/git.txt9
-rw-r--r--cache.h6
-rw-r--r--environment.c15
-rwxr-xr-xt/t3040-subprojects-basic.sh2
-rwxr-xr-xt/t4013-diff-various.sh2
-rwxr-xr-xt/t9300-fast-import.sh2
6 files changed, 33 insertions, 3 deletions
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 7a1d629..6ec871b 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -709,6 +709,15 @@ of clones and fetches.
the background which do not want to cause lock contention with
other operations on the repository. Defaults to `1`.
+`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 d74f00d..1003178 100644
--- a/cache.h
+++ b/cache.h
@@ -1942,4 +1942,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 8289c25..a3abdd3 100644
--- a/environment.c
+++ b/environment.c
@@ -343,3 +343,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 0a4ff6d..b81eb5f 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 c515e3e..9bed64d 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 d47560b..e4d06ac 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
'