git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Keeping <john@keeping.me.uk>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jonathan Nieder <jrnieder@gmail.com>,
	Jens Lehmann <Jens.Lehmann@web.de>,
	Heiko Voigt <hvoigt@hvoigt.net>
Subject: Re: [PATCH v2 1/2] rev-parse: add --filename-prefix option
Date: Tue, 9 Apr 2013 22:28:27 +0100	[thread overview]
Message-ID: <20130409212827.GG2222@serenity.lan> (raw)
In-Reply-To: <7vtxnfpglq.fsf@alter.siamese.dyndns.org>

On Tue, Apr 09, 2013 at 01:57:21PM -0700, Junio C Hamano wrote:
> John Keeping <john@keeping.me.uk> writes:
> 
> > This adds a prefix string to any filename arguments encountered after it
> > has been specified.
> >
> > Signed-off-by: John Keeping <john@keeping.me.uk>
> > ---
> 
> Stale subject?

Yep.  Sorry.

> > +--prefix <arg>::
> > +	Behave as if 'git rev-parse' was invoked from the `<arg>`
> > +	subdirectory of the working tree.  Any relative filenames are
> > +	resolved as if they are prefixed by `<arg>` and will be printed
> > +	in that form.
> > ++
> > +This can be used to convert arguments to a command run in a subdirectory
> > +so that they can still be used after moving to the top-level of the
> > +repository.  For example:
> > ++
> > +----
> > +prefix=$(git rev-parse --show-prefix)
> > +cd "$(git rev-parse --show-toplevel)"
> > +eval "set -- $(git rev-parse --sq --prefix "$prefix" "$@")"
> 
> I think you should tighten rev-parse parameter to reject options and
> revisions, especially as an example to teach how to use it.  When
> the user said
> 
> 	git mylog -U20 master..next -- README
> 
> inside Documentation/ directory,  "git-mylog" script would want to
> see README prefixed with Documentation/ but want to see -U20 or
> master..next untouched.

And it will if it runs:

	git rev-parse --prefix Documentation/ -U20 master..next -- README

Which gives:

	-U20
	f131fb6eb2a1e09f7ce53d148e21ce6960f42422
	^fa7285dc3dce8bd01fd8c665b032603ed55348e5
	--
	Documentation/README

>                          Historically, rev-parse was a way to sift
> options and args meant for rev-list from those mant for diff-tree
> so that a variant of
> 
> 	git rev-list $(git rev-parse --revs) "$@" |
>         git diff-tree --stdin $(git rev-parse --no-revs)
> 
> can be used to implement such "git mylog" script.
> 
> I think "--no-revs --no-flags" is how you ask it to give you only
> the paths, but I am writing from memory so please double check.
> 
> Having said all that.
> 
> Existing scripts (e.g. "git am") do this kind of things without such
> an option added to rev-parse.  They first do:
> 
>     prefix=$(git rev-parse --show-prefix)
> 
> and refer to "$prefix/$1", "$prefix/$2", etc., I think.
> 
> Is this option really necessary to update "git submodule"?  Don't we
> have a much better idea which parameter holds user-supplied path in the
> script than having rev-parse make a guess on the entire "$@"?

It's not guessing on all of "$@" in git-submodule - we know that
everything left is a path.

I've looked at git-am and hadn't thought of doing that, just thought
this was a reasonably elegant way of processing the arguments.  I'm
happy to try another approach if that's going to be more acceptable.

  reply	other threads:[~2013-04-09 21:28 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-07 19:55 [RFC/PATCH 0/2] submodule: drop the top-level requirement John Keeping
2013-04-07 19:55 ` [PATCH 1/2] rev-parse: add --filename-prefix option John Keeping
2013-04-07 22:14   ` Jonathan Nieder
2013-04-08  8:31     ` John Keeping
2013-04-08 15:07       ` Junio C Hamano
2013-04-08 17:36         ` John Keeping
2013-04-08 18:11           ` Junio C Hamano
2013-04-07 19:55 ` [PATCH 2/2] submodule: drop the top-level requirement John Keeping
2013-04-07 20:15 ` [RFC/PATCH 0/2] " Jens Lehmann
2013-04-09 20:29 ` [PATCH v2 " John Keeping
2013-04-09 20:29   ` [PATCH v2 1/2] rev-parse: add --filename-prefix option John Keeping
2013-04-09 20:57     ` Junio C Hamano
2013-04-09 21:28       ` John Keeping [this message]
2013-04-09 21:33         ` Junio C Hamano
2013-04-18 14:28     ` Ramkumar Ramachandra
2013-04-18 14:42       ` John Keeping
2013-04-09 20:29   ` [PATCH v2 2/2] submodule: drop the top-level requirement John Keeping
2013-04-09 21:00     ` Junio C Hamano
2013-04-09 21:29       ` John Keeping
2013-04-18 14:46     ` Ramkumar Ramachandra
2013-04-18 14:56       ` John Keeping
2013-04-18 19:50   ` [PATCH v3 0/2] " John Keeping
2013-04-18 19:50     ` [PATCH v3 1/2] rev-parse: add --prefix option John Keeping
2013-04-19  9:53       ` Ramkumar Ramachandra
2013-04-19 10:22         ` John Keeping
2013-04-19 11:15           ` Ramkumar Ramachandra
2013-04-19 11:25             ` John Keeping
2013-04-19 11:29               ` Ramkumar Ramachandra
2013-04-18 19:50     ` [PATCH v3 2/2] submodule: drop the top-level requirement John Keeping
2013-04-18 22:40       ` Junio C Hamano
2013-04-19  7:46         ` John Keeping
2013-04-19 16:45           ` Junio C Hamano
2013-04-19 19:23             ` Johannes Sixt
2013-04-19 21:03               ` Junio C Hamano
2013-04-24  8:15                 ` [PATCH] submodule: fix quoting in relative_path() John Keeping
2013-04-24 16:21                   ` Junio C Hamano
2013-04-24 16:28                     ` John Keeping
2013-04-24 19:12                       ` Johannes Sixt
2013-04-18 23:54       ` [PATCH v3 2/2] submodule: drop the top-level requirement Eric Sunshine

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

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

  git send-email \
    --in-reply-to=20130409212827.GG2222@serenity.lan \
    --to=john@keeping.me.uk \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hvoigt@hvoigt.net \
    --cc=jrnieder@gmail.com \
    /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.
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 NNTP newsgroup(s).