summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 979f792)
raw | patch | inline | side by side (parent: 979f792)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 9 Dec 2010 21:38:05 +0000 (13:38 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 9 Dec 2010 21:38:05 +0000 (13:38 -0800) |
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>
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>
sha1_name.c | patch | blob | history | |
t/t1506-rev-parse-diagnosis.sh | patch | blob | history |
diff --git a/sha1_name.c b/sha1_name.c
index f918faf5c7e635b1a3ad9e9e423cefabfbac4ead..207405688bb919363c0fdde31083f2e57d26e050 100644 (file)
--- a/sha1_name.c
+++ b/sha1_name.c
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));
index 18664702b968102f393be836306a833731790e80..9f8adb1f824a5bafe8829e5ab613e2ab83065f4f 100755 (executable)
test_expect_success 'correct relative file objects (0)' '
git rev-parse :file.txt >expected &&
git rev-parse :./file.txt >result &&
+ test_cmp expected result &&
+ git rev-parse :0:./file.txt >result &&
test_cmp expected result
'
)
'
+test_expect_success 'correct relative file objects (5)' '
+ git rev-parse :subdir/file.txt >expected &&
+ (
+ cd subdir &&
+ git rev-parse :./file.txt >result &&
+ test_cmp ../expected result &&
+ git rev-parse :0:./file.txt >result &&
+ test_cmp ../expected result
+ )
+'
+
+test_expect_success 'correct relative file objects (6)' '
+ git rev-parse :file.txt >expected &&
+ (
+ cd subdir &&
+ git rev-parse :../file.txt >result &&
+ test_cmp ../expected result &&
+ git rev-parse :0:../file.txt >result &&
+ test_cmp ../expected result
+ )
+'
+
test_expect_success 'incorrect revision id' '
test_must_fail git rev-parse foobar:file.txt 2>error &&
grep "Invalid object name '"'"'foobar'"'"'." error &&