rev-parse: add option for absolute or relative path formatting
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sun, 13 Dec 2020 00:25:29 +0000 (00:25 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 13 Dec 2020 07:35:51 +0000 (23:35 -0800)
commitfac60b89252e5865da077bb6ccaa9bef43efbfeb
treed6e56599862333b790b5a2b75c10620f9aeac5dd
parentbe6e0daee700b2ee28846b54ddfefe08cd4ec506
rev-parse: add option for absolute or relative path formatting

git rev-parse has several options which print various paths.  Some of
these paths are printed relative to the current working directory, and
some are absolute.

Normally, this is not a problem, but there are times when one wants
paths entirely in one format or another.  This can be done trivially if
the paths are canonical, but canonicalizing paths is not possible on
some shell scripting environments which lack realpath(1) and also in Go,
which lacks functions that properly canonicalize paths on Windows.

To help out the scripter, let's provide an option which turns most of
the paths printed by git rev-parse to be either relative to the current
working directory or absolute and canonical.  Document which options are
affected and which are not so that users are not confused.

This approach is cleaner and tidier than providing duplicates of
existing options which are either relative or absolute.

Note that if the user needs both forms, it is possible to pass an
additional option in the middle of the command line which changes the
behavior of subsequent operations.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-rev-parse.txt
builtin/rev-parse.c
t/t1500-rev-parse.sh