Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-12-10 00:38:05 +0300
committerJunio C Hamano <gitster@pobox.com>2010-12-10 00:38:05 +0300
commit3d6e0f745e5b958387c9116ff5ba6247b990e6e7 (patch)
treef4b3b7e72272491fa01df6c8a750f4bcdf648f1a /sha1_name.c
parent979f792951913d75f992f87022b75610303a614f (diff)
get_sha1: teach ":$n:<path>" the same relative path logic
We taught the object name parser to take ":./<path>", ":../<path>", etc. and understand them to be relative to the current working directory. Given that ":<path>" is just a short-hand for ":0:<path>" (i.e. "take stage #0 of that path"), we should allow ":$n:<path>" to interpret them the same way. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sha1_name.c b/sha1_name.c
index f918faf5c7..207405688b 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1091,17 +1091,19 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
return get_sha1_oneline(name + 2, sha1);
if (namelen < 3 ||
name[2] != ':' ||
- name[1] < '0' || '3' < name[1]) {
+ name[1] < '0' || '3' < name[1])
cp = name + 1;
- new_path = resolve_relative_path(cp);
- if (new_path)
- cp = new_path;
- }
else {
stage = name[1] - '0';
cp = name + 3;
}
- namelen = strlen(cp);
+ new_path = resolve_relative_path(cp);
+ if (!new_path) {
+ namelen = namelen - (cp - name);
+ } else {
+ cp = new_path;
+ namelen = strlen(cp);
+ }
strncpy(oc->path, cp,
sizeof(oc->path));