Skip to content

pr-git-1470/john-cai/jc/attr-source-git-flag-v6

From: John Cai <johncai86@gmail.com>

Earlier, 47cfc9bd (attr: add flag `--source` to work with tree-ish,
2023-01-14) taught "git check-attr" the "--source=<tree>" option to
allow it to read attribute files from a tree-ish, but did so only
for the command.  Just like "check-attr" users wanted a way to use
attributes from a tree-ish and not from the working tree files,
users of other commands (like "git diff") would benefit from the
same.

Undo most of the UI change the commit made, while keeping the
internal logic to read attributes from a given tree-ish. Expose the
internal logic via a new "--attr-source=<tree>" command line option
given to "git", so that it can be used with any git command that
runs as part of the main git process.

Additionally, add an environment variable GIT_ATTR_SOURCE that is set
when --attr-source is passed in, so that subprocesses use the same value
for the attributes source tree.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Submitted-As: https://lore.kernel.org/git/pull.1470.v6.git.git.1683346530487.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.1470.git.git.1679109928556.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.1470.v2.git.git.1679936543320.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.1470.v3.git.git.1682707848916.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.1470.v4.git.git.1682822352360.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.1470.v5.git.git.1683144574158.gitgitgadget@gmail.com
Assets 2