diff options
author | Jeff King <peff@peff.net> | 2016-09-12 20:23:32 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-09-13 15:45:45 -0700 |
commit | 7d8930d903fd8b775a1db63bcf373df5ac5af0be (patch) | |
tree | 1b1270925f748b945d1865946835488ad4b06109 /builtin/log.c | |
parent | diff: skip implicit no-index check when given --no-index (diff) | |
download | tgif-7d8930d903fd8b775a1db63bcf373df5ac5af0be.tar.xz |
diff: handle --no-index prefixes consistently
If we see an explicit "git diff --no-index ../foo ../bar",
then we do not set up the git repository at all (we already
know we are in --no-index mode, so do not have to check "are
we in a repository?"), and hence have no "prefix" within the
repository. A patch generated by this command will have the
filenames "a/../foo" and "b/../bar", no matter which
directory we are in with respect to any repository.
However, in the implicit case, where we notice that the
files are outside the repository, we will have chdir()'d to
the top-level of the repository. We then feed the prefix
back to the diff machinery. As a result, running the same
diff from a subdirectory will result in paths that look like
"a/subdir/../../foo".
Besides being unnecessarily long, this may also be confusing
to the user: they don't care about the subdir or the
repository at all; it's just where they happened to be when
running the command. We should treat this the same as the
explicit --no-index case.
One way to address this would be to chdir() back to the
original path before running our diff. However, that's a bit
hacky, as we would also need to adjust $GIT_DIR, which could
be a relative path from our top-level.
Instead, we can reuse the diff machinery's RELATIVE_NAME
option, which automatically strips off the prefix. Note that
this _also_ restricts the diff to this relative prefix, but
that's OK for our purposes: we queue our own diff pairs
manually, and do not rely on that part of the diff code.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/log.c')
0 files changed, 0 insertions, 0 deletions