File: 0003-remove-interpreter-line-from-shell-libraries.diff

package info (click to toggle)
git 1%3A1.7.10.4-1%2Bwheezy3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 22,468 kB
  • sloc: ansic: 131,677; sh: 101,927; perl: 25,746; tcl: 20,816; python: 4,441; makefile: 3,418; lisp: 1,785; asm: 98
file content (169 lines) | stat: -rw-r--r-- 6,139 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
From d65b91ebbdffcb07ffe17628ca0fce9182ce1dfe Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnieder@gmail.com>
Date: Tue, 13 Mar 2012 20:01:17 -0500
Subject: [PATCH 03/12] remove #!interpreter line from shell libraries

In a shell snippet meant to be sourced by another shell script,
an initial #!/bin/sh line is just a comment and has no effect on
the script's functionality.

Some people include such a shebang line anyway, as a familiar way of
documenting what format the file is in.  However, it is even clearer
to include a comment and no shebang at all, to avoid creating the
illusion that the indicated choice of shell will have some effect.
Add some text to git's shell libraries explaining in what context the
fragments are meant to be sourced and remove the shebangs.

As a happy side effect, vim no longer recognizes the file type of
files like git-sh-setup without the ".sh" suffix, which should steer
people toward the git-sh-setup.sh source file.  Thanks to Clemens
Buchacher for noticing.

Complications (thanks to Jeff King for finding these):

- As explained in v1.7.6-rc3~7 (tests: link shell libraries into
  valgrind directory, 2011-06-17), the valgrind support in test
  scripts uses the shebang line to recognize shell libraries which
  should be symlinked into $GIT_VALGRIND/bin/ along with the wrapped
  executables.  This patch tweaks the rule to look for a comment
  starting with "# " in the first line instead.

- Because these files are not marked executable (see v1.7.1-rc0~143^2,
  2010-01-31), the lack of #! line will not confuse the valgrind
  support of our test scripts into replacing the shell libraries with
  the valgrind.sh wrapper (see v1.7.0-rc1~9, 2009-11-25), so this should
  be safe.

Suggested by Russ Allbery through lintian.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 git-mergetool--lib.sh      |    3 +--
 git-parse-remote.sh        |    4 +++-
 git-rebase--am.sh          |    3 ++-
 git-rebase--interactive.sh |    8 +++-----
 git-rebase--merge.sh       |    4 +++-
 git-sh-i18n.sh             |    5 ++---
 git-sh-setup.sh            |    9 +++------
 t/test-lib.sh              |    6 ++----
 8 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index ed630b2..7a0f499 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -1,5 +1,4 @@
-#!/bin/sh
-# git-mergetool--lib is a library for common merge tool functions
+# git-mergetool--lib is a shell library for common merge tool functions
 diff_mode() {
 	test "$TOOL_MODE" = diff
 }
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 484b2e6..10cae3f 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -1,4 +1,6 @@
-#!/bin/sh
+# This is a shell library to calculate the remote repository and
+# upstream branch that should be pulled by "git pull" from the current
+# branch.
 
 # git-ls-remote could be called from outside a git managed repository;
 # this would fail in that case and would issue an error message.
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index c815a24..5d8d451 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -1,4 +1,5 @@
-#!/bin/sh
+# This shell script fragment is sourced by git-rebase to implement
+# its default, fast, patch-based, non-interactive mode.
 #
 # Copyright (c) 2010 Junio C Hamano.
 #
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 2e13258..394c85f 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -1,11 +1,9 @@
-#!/bin/sh
 #
 # Copyright (c) 2006 Johannes E. Schindelin
 
-# SHORT DESCRIPTION
-#
-# This script makes it easy to fix up commits in the middle of a series,
-# and rearrange commits.
+# This shell script fragment is sourced by git-rebase to implement
+# its interactive mode.  "git rebase --interactive" makes it easy
+# to fix up commits in the middle of a series and rearrange commits.
 #
 # The original idea comes from Eric W. Biederman, in
 # http://article.gmane.org/gmane.comp.version-control.git/22407
diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
index dc59907..0fa0e49 100644
--- a/git-rebase--merge.sh
+++ b/git-rebase--merge.sh
@@ -1,4 +1,6 @@
-#!/bin/sh
+# This shell script fragment is sourced by git-rebase to implement
+# its merge-based non-interactive mode that copes well with renamed
+# files.
 #
 # Copyright (c) 2010 Junio C Hamano.
 #
diff --git a/git-sh-i18n.sh b/git-sh-i18n.sh
index 6a27f68..e6c3116 100644
--- a/git-sh-i18n.sh
+++ b/git-sh-i18n.sh
@@ -1,9 +1,8 @@
-#!/bin/sh
+# This shell library is Git's interface to gettext.sh. See po/README
+# for usage instructions.
 #
 # Copyright (c) 2010 Ævar Arnfjörð Bjarmason
 #
-# This is Git's interface to gettext.sh. See po/README for usage
-# instructions.
 
 # Export the TEXTDOMAIN* data that we need for Git
 TEXTDOMAIN=git
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 5d8e4e6..51362d6 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -1,9 +1,6 @@
-#!/bin/sh
-#
-# This is included in commands that either have to be run from the toplevel
-# of the repository, or with GIT_DIR environment variable properly.
-# If the GIT_DIR does not look like the right correct git-repository,
-# it dies.
+# This shell scriplet is meant to be included by other shell scripts
+# to set up some variables pointing at the normal git directories and
+# a few helper shell functions.
 
 # Having this variable in your environment would break scripts because
 # you would cause "cd" to be taken to unexpected places.  If you
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 9e2b711..62beadd 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -420,11 +420,9 @@ then
 
 	make_valgrind_symlink () {
 		# handle only executables, unless they are shell libraries that
-		# need to be in the exec-path.  We will just use "#!" as a
-		# guess for a shell-script, since we have no idea what the user
-		# may have configured as the shell path.
+		# need to be in the exec-path.
 		test -x "$1" ||
-		test "#!" = "$(head -c 2 <"$1")" ||
+		test "# " = "$(head -c 2 <"$1")" ||
 		return;
 
 		base=$(basename "$1")
-- 
1.7.10