git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] get_sha1: support relative path ":path" syntax

From
Thiago Farina <tfransosi@gmail.com>
Date
Nov 14, 2010, 20:22 UTC
Message-ID
<AANLkTimJKQ=xc7az+FEM+18aTxQ5zQ24q7pfChnSwt6f@mail.gmail.com>
In-Reply-To
<1289484484-8632-4-git-send-email-pclouds@gmail.com>
2010/11/11 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
Show 29 quoted lines
> 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 for which startup_info is NULL
> (i.e. non-builtin ones, it seems none of them needs this anyway).
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  sha1_name.c                    |   37 ++++++++++++++++++++++--
>  t/t1506-rev-parse-diagnosis.sh |   62 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 96 insertions(+), 3 deletions(-)
>
> diff --git a/sha1_name.c b/sha1_name.c
> index 484081d..22c1df9 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -1046,6 +1046,23 @@ int get_sha1_with_mode_1(const char *name, unsigned char *sha1, unsigned *mode,
>        return ret;
>  }
>
> +static char *resolve_relative_path(const char *rel)
> +{
> +       if (prefixcmp(rel, "./") && prefixcmp(rel, "../"))
> +               return NULL;
> +
> +       if (!startup_info)
> +               die("Relative path syntax is not supported in this command. Please report.");

Is the "Please report." necessary? Report to who? Where? (I know we know these answers, but maybe a new user won't know them).

> +
> +       if (!is_inside_work_tree())
> +               die("relative path syntax can't be used outside working tree.");
nit: s/relative/Relative ?
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 5 of 12 in “Support relative path in <blah>:path syntax”
  1. 0/3 Support relative path in <blah>:path syntaxNguyễn Thái Ngọc Duy, Nov 11, 2010
  2. 1/3 setup: save prefix (original cwd relative to toplevel) in startup_infoNguyễn Thái Ngọc Duy, Nov 11, 2010
  3. 2/3 Make prefix_path() return char* without constNguyễn Thái Ngọc Duy, Nov 11, 2010
  4. 3/3 get_sha1: support relative path ":path" syntaxNguyễn Thái Ngọc Duy, Nov 11, 2010
  5. Thiago FarinaNov 14, 2010
  6. get_sha1: support relative path ":path" syntaxNguyễn Thái Ngọc Duy, Nov 15, 2010
  7. Sverre RabbelierNov 15, 2010
  8. Junio C HamanoNov 15, 2010
  9. Junio C HamanoNov 15, 2010
  10. get_sha1: support relative path ":path" syntaxNguyễn Thái Ngọc Duy, Nov 28, 2010
  11. Junio C HamanoNov 17, 2010
  12. Nguyen Thai Ngoc DuyNov 18, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.