Re: [PATCH 3/3] get_sha1: support relative path ":path" syntax
From: Thiago Farina <hidden>
Date: 2016-06-15 22:50:02
2010/11/11 Nguyễn Thái Ngọc Duy [off-list ref]:
quoted hunk ↗ jump to hunk
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 <redacted> --- 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 ?