From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, jnareb@gmail.com, dirson@bertin.fr,
kevin@sb.org, gitster@pobox.com, peff@peff.net
Subject: Re: [PATCH] get_sha1: support relative path "<obj>:<sth>" syntax
Date: Wed, 10 Nov 2010 18:17:50 +0100 [thread overview]
Message-ID: <vpq39r9m729.fsf@bauges.imag.fr> (raw)
In-Reply-To: <1289407021-30287-1-git-send-email-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Wed\, 10 Nov 2010 23\:37\:01 +0700")
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> Currently :path and ref:path can be used to refer to a specific object
> in index or ref respectively. "path" component is absolute path. This
> patch allows "path" to be written as "./path" or "../path", which is
> relative to user's original cwd.
>
> This does not work in commands that startup_info is NULL
Grammar: shouldn't it be "commands for which startup_info is NULL"?
> (i.e. non-builtin ones).
Does that include "git show"? That's probably the most common use-case
for the <object>:<path> syntax, perhaps worth mentionning here.
Also, what happens when it doesn't work? I guess it falls back to the
previous behavior, which tries to do a detailed diagnosis and provides
a general error message. But probably the error messages should be
reworded to include "syntax not supported by this command" or so,
'cause it's really weird for a user to be able to say HEAD:./foo in
some places and not in others.
> The idea is old although I don't remember if anybody has made any
> attempt to realize it: use './' and '../' to specify the given path
> is relative, not absolute.
I gave it a try, but I was not aware of the startup_info thing, and
tried passing more arguments to get_sha1*, and you can guess I quickly
gave up ;-).
> + if (startup_info && cp[0] == '.' &&
> + (cp[1] == '/' || (cp[1] == '.' && cp[2] == '/'))) {
Nothing performance-critical here, so I'd rather have something more
readable, like
startup_info && (!prefixcmp(cp, "./") || !prefixcmp(cp, "../"))
> + new_path = prefix_path(startup_info->prefix,
> + strlen(startup_info->prefix),
> + cp);
free(cp); here?
> + cp = new_path;
> + }
> + }
> @@ -1122,6 +1134,17 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
> }
> if (!get_sha1_1(name, cp-name, tree_sha1)) {
> const char *filename = cp+1;
> + char *new_filename = NULL;
> +
> + if (startup_info &&
> + filename[0] == '.' &&
> + (filename[1] == '/' ||
> + (filename[1] == '.' && filename[2] == '/'))) {
> + new_filename = prefix_path(startup_info->prefix,
> + strlen(startup_info->prefix),
> + filename);
Same 2 questions as above.
Also, that would be nice is this came with a testcase :-)
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
next prev parent reply other threads:[~2010-11-10 17:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-09 7:30 [RFC] Using gitrevisions :/search style with other operators Yann Dirson
2010-11-09 8:06 ` Kevin Ballard
2010-11-09 9:24 ` Yann Dirson
2010-11-10 0:18 ` Junio C Hamano
2010-11-10 0:33 ` Kevin Ballard
2010-11-10 7:32 ` Yann Dirson
2010-11-10 7:46 ` Kevin Ballard
2010-11-10 7:46 ` Yann Dirson
2010-11-10 15:26 ` Jakub Narebski
2010-11-10 16:37 ` [PATCH] get_sha1: support relative path "<obj>:<sth>" syntax Nguyễn Thái Ngọc Duy
2010-11-10 17:17 ` Matthieu Moy [this message]
2010-11-10 17:47 ` Jonathan Nieder
2010-11-11 13:18 ` Nguyen Thai Ngoc Duy
2010-11-10 19:34 ` Junio C Hamano
2010-11-11 1:30 ` Nguyen Thai Ngoc Duy
2010-12-09 21:10 ` Junio C Hamano
2010-12-09 21:37 ` Junio C Hamano
2010-12-10 1:35 ` Nguyen Thai Ngoc Duy
2010-11-10 17:23 ` [RFC] Using gitrevisions :/search style with other operators Junio C Hamano
2010-11-10 18:19 ` Jakub Narebski
2010-11-09 16:10 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpq39r9m729.fsf@bauges.imag.fr \
--to=matthieu.moy@grenoble-inp.fr \
--cc=dirson@bertin.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.com \
--cc=kevin@sb.org \
--cc=pclouds@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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.