Skip to content

Commit 5501f50

Browse files
Tauwassergitster
authored andcommitted
git-prompt: make __git_eread intended use explicit
__git_eread is used to read a single line of a given file (if it exists) into a single variable stripping the EOL. This patch removes the unused capability to split file contents into tokens by passing multiple variable names. Add a comment and explicitly use $2 instead of misleading $@ as argument to the read builtin command. Signed-off-by: Robert Abel <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9b185be commit 5501f50

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

contrib/completion/git-prompt.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,12 @@ __git_ps1_colorize_gitstring ()
278278
r="$c_clear$r"
279279
}
280280

281+
# Helper function to read the first line of a file into a variable.
282+
# __git_eread requires 2 arguments, the file path and the name of the
283+
# variable, in that order.
281284
__git_eread ()
282285
{
283-
local f="$1"
284-
shift
285-
test -r "$f" && read "$@" <"$f"
286+
test -r "$1" && read "$2" <"$1"
286287
}
287288

288289
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)

0 commit comments

Comments
 (0)