From: Jeff King <peff@peff.net>
To: "Benoît Person" <benoit.person@ensimag.fr>
Cc: git@vger.kernel.org, "Célestin Matte" <celestin.matte@ensimag.fr>,
"Matthieu Moy" <matthieu.moy@grenoble-inp.fr>
Subject: Re: [PATCH/RFC] git-remote-mediawiki: new tool to preview local changes without pushing
Date: Sun, 9 Jun 2013 14:32:47 -0400 [thread overview]
Message-ID: <20130609183247.GF810@sigill.intra.peff.net> (raw)
In-Reply-To: <CAETqRCh9frekD8yiR0bE+WQ7b_et1th8p_LsqrL8NhPnC8yaow@mail.gmail.com>
On Sun, Jun 09, 2013 at 02:35:45PM +0200, Benoît Person wrote:
> On 9 June 2013 08:08, Jeff King <peff@peff.net> wrote:
> > I also wonder if it would be useful to be able to specify not only files
> > in the filesystem, but also arbitrary blobs. So in 4b above, you could
> > "git mw preview origin:page.mw" to see the rendered version of what
> > upstream has done.
>
> Hum, so `git mw preview origin:page.mw` would just do the get
> request to the remote mediawiki, save it locally and - maybe - load it
> in the browser ? Is it really better than just opening the browser and
> typing the right URL ?
Not really, but when you start doing "origin^:page.mw", it may make more
of a difference.
> > If you just care about the remote name and not the name of the local
> > branch, you can just ask for
> >
> > my $curr_branch = `git symbolic-ref HEAD`;
> > my $remote = `git config "branch.$curr_branch.remote"`;
> > my $url = `git config "remote.$remote.url"`;
> >
> > Of course you would want some error checks and probably some chomp()s in
> > there, too.
>
> The fact is, `git symbolic-ref HEAD` result would have to be parsed in order
> to extract the current branch name like I currently extract the remote name.
> So, is it really better than `git rev-parse --symbolic-full-name @{upstream}` ?
It is, because it is not strictly true that an upstream of
"refs/remotes/foo/*" is for the remote "foo" (though in 99% of cases, it
is). To find the upstream, git looks at branch.$curr_branch.remote, then
calculates the upstream based on the fetch refspecs. Then you try to
undo that by converting it back from the right-hand side of the fetch
refspec into a remote name. It would be much easier to just look at the
config. :)
And yes, you do need the short name of the branch from HEAD, not the
full refname. You can use "git symbolic-ref --short" for that. You also
should check that it returns something useful (i.e., that we are not on
a detached HEAD).
> > That is probably OK as long as there is only one such remote, and it
> > would help the case where you have branched off of a local branch (so
> > your upstream remote is "."). If there are two mediawiki remotes,
> > though, it would make sense to simply fail, as you don't know which to
> > use. But I'd expect the common case by far to be that you simply have
> > one such remote.
>
> Well, I thought that `git mw preview` could provide an interactive mode
> where, if the first search fails, it would find all the mediawiki remotes, and
> offers to the user a way to choose the remote ?
That's fine; just as long as we do not silently produce output from an
unknown source when there is ambiguity.
You can do an interactive selection, or even just say something like:
There are multiple mediawiki remotes, and I do not know which one you
want to use for your preview. Which of:
remote1
remote2
did you mean? Try using the "-r" option to specify the remote.
and then let the user repeat their command with the "-r" option using
shell history. That saves you from having to write an interactive
component, and teaches the user how to script it.
-Peff
next prev parent reply other threads:[~2013-06-09 18:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 21:50 [PATCH/RFC] git-remote-mediawiki: new tool to preview local changes without pushing benoit.person
2013-06-08 19:00 ` Matthieu Moy
2013-06-09 6:12 ` Jeff King
2013-06-09 6:08 ` Jeff King
2013-06-09 11:01 ` Matthieu Moy
2013-06-09 12:18 ` Benoît Person
2013-06-09 18:13 ` Jeff King
2013-06-09 12:35 ` Benoît Person
2013-06-09 14:37 ` Matthieu Moy
2013-06-09 18:32 ` Jeff King [this message]
2013-06-11 21:31 ` Benoît Person
2013-06-11 21:37 ` Jeff King
2013-06-12 6:55 ` Matthieu Moy
2013-06-12 8:55 ` Jeff King
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=20130609183247.GF810@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=benoit.person@ensimag.fr \
--cc=celestin.matte@ensimag.fr \
--cc=git@vger.kernel.org \
--cc=matthieu.moy@grenoble-inp.fr \
/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).