Thread (23 messages) flat view 23 messages, 3 authors, 2016-06-15

Re: [WIP PATCH 01/18] rev-parse: add --internal-cwd and --internal-git-dir for tests

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:49:52

2010/10/24 Jonathan Nieder [off-list ref]:
Nguyễn Thái Ngọc Duy wrote:
quoted
--internal-cwd is obvious, no way else to expose it for testing.

--internal-git-dir is introduced because --git-dir prepares its output
suitable for scripting. For tests, it must be exactly what git stores.
Hmm.  Forget this is used in tests, would it make sense to do this
with trace_printf, at the end of setup, as in your earlier patch?
trace_printf surely does. But "the end of setup" is unclear. As of
now, setup ends when setup_* function _and_ setup_git_env() are
called. There are cases that setup_* finishes without calling
setup_git_env(), or setup_git_env() is called way before setup_* is
finished.
I think it might: just like the exec: lines provide context about what
command is being traced, such trace: cwd: lines would make it clearer
what paths that are being output might be referring to.
Also prefix them all with "setup:", something like

setup: git_dir: ../.git
setup: work_tree: /my/git/worktree
setup: cwd: /my/git/worktree
setup: prefix: sub/

would be easy to be grepped from GIT_TRACE, to read and to test_cmp.
Returning to the topic of tests, is it possible to get at these
variables using an external command that is run by git?  pre-commit
hook, maybe.  Testing of other symptoms is also possible, as in
Frédéric's example.
Why do hooks need these? git_dir, prefix are already accessible via
--git-dir, --show-prefix, --show-toplevel. Current cwd can be
determined with --is-inside-work-tree: if it returns true, current cwd
is worktree root, otherwise it is original cwd.
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help