git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Kyle J. McKay" <mackyle@gmail.com>,
	git@vger.kernel.org, Jens Lehmann <Jens.Lehmann@web.de>
Subject: Re: [PATCH] test: fix t7001 cp to use POSIX options
Date: Fri, 11 Apr 2014 12:23:59 -0700	[thread overview]
Message-ID: <xmqq1tx3u0ts.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20140411114338.GD28858@sigill.intra.peff.net> (Jeff King's message of "Fri, 11 Apr 2014 07:43:38 -0400")

Jeff King <peff@peff.net> writes:

> On Fri, Apr 11, 2014 at 01:24:02AM -0700, Kyle J. McKay wrote:
>
>> Since 11502468 and 04c1ee57 (both first appearing in v1.8.5), the
>> t7001-mv test has used "cp -a" to perform a copy in several of the
>> tests.
>> 
>> However, the "-a" option is not required for a POSIX cp utility and
>> some platforms' cp utilities do not support it.
>> 
>> The POSIX equivalent of -a is -R -P -p.
>> 
>> Change "cp -a" to "cp -R -P -p" so that the t7001-mv test works
>> on systems with a cp utility that only implements the POSIX
>> required set of options and not the "-a" option.
>
> I wonder if the "-R" is the part that we actually care about here.
> Including the others does not hurt in that case, but using only "-R"
> would perhaps make it more obvious to a later reader of the code exactly
> what we are trying to do.

These calls to "cp" are about "We know that earlier 'update' created
the GIT_DIR of the submodule in the top-level superproject, because
we are running a modern Git.  But we want to make sure the command
we are testing, "git mv", would work correctly if the repository
were made with an older Git that created the GIT_DIR embedded in the
working tree of the submodule, so let's emulate that case."  As we
create files and directories in GIT_DIR with explicit permission
bits, we may care about

 (1) making sure "git mv" can actually move the directory, with some
     paths having mode bits different from the umasked default; and

 (2) checking that the GIT_DIR after "git mv" has the permission
     bits right.

and if we cared, "-R -p" would be required here, not just "-R".

If core.prefersymlinkrefs is set, GIT_DIR would have a symbolic link
HEAD pointing at the current branch, and "-P" may become relevant,
but manually running "cp -R .git git && ls -l git/HEAD" in such an
old repository tells me that symbolic link HEAD is not dereferenced
without an explicit "-L", so I dunno.

Because we do not check anything inside GIT_DIR of the moved
submodule after "git mv" is done, the more correct use of "cp" is
moot for the purpose of (2), but it could be possible that "git mv"
fails to move a submodule with GIT_DIR created embedded in its
working tree by an older version of Git, while successfully copying
an emulated one, due to differences such as modes and symlinks.

The current implementation just does rename(2) on the whole
submodule working tree and let its contents move together, so I do
not think it matters at the moment for the purpose of (1); use of
flags other than "-R" are purely for future-proofing, I would think.

  parent reply	other threads:[~2014-04-11 19:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-11  8:24 [PATCH] test: fix t7001 cp to use POSIX options Kyle J. McKay
2014-04-11 11:43 ` Jeff King
2014-04-11 13:44   ` Kyle J. McKay
2014-04-11 19:23   ` Junio C Hamano [this message]
2014-04-12 21:52     ` Jens Lehmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1tx3u0ts.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=mackyle@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).