{"thread":{"id":"43084","subject":"[PATCH] git-pickaxe: look for files relative to current path","startedAt":"2006-11-02T03:21:22Z","lastAt":"2006-11-02T07:22:49Z","messageCount":2,"participants":["Jeff King","Andy Whitcroft"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"295803","messageId":"45496432.80503@shadowen.org","threadId":"43084","inReplyTo":null,"subject":"git pickaxe -- problems with relative filenames","fromName":"Andy Whitcroft","fromEmail":"apw@shadowen.org","sentAt":"2006-11-02T03:21:22Z","receivedAt":"2006-11-02T03:21:22Z","isPatch":false,"sender":{"key":"apw@shadowen.org","avatar":"https://gravatar.com/avatar/d3088262854661a913ef35cc40fedcc270142d4461791142bc1ea0b2a4e2e147?d=mp&s=160"},"body":"We seem to have a difference in the handling of relative filenames\nwithin a repository between git blame and git pickaxe.  Specifically git\npickaxe seems to always require names as if it were run in the top of\nthe project:\n\napw@pinky$ pwd\n/home/apw/git/git/Documentation\napw@pinky$ git blame git.txt | head -2\n7984eabe (Sebastian Kuzminsky 2005-05-19 10:24:54 -0600   1) git(7)\n2cf565c5 (David Greaves       2005-05-10 22:32:30 +0100   2) ======\napw@pinky$ git pickaxe git.txt | head -2\nfatal: cannot stat path git.txt: No such file or directory\napw@pinky$ git pickaxe Documentation/git.txt | head -2\n7984eabe (Sebastian Kuzminsky 2005-05-19 10:24:54 -0600   1) git(7)\n2cf565c5 (David Greaves       2005-05-10 22:32:30 +0100   2) ======\n\nThis seems inconsistent? Is this expected behaviour?\n\n"},{"id":"293825","messageId":"20061102072249.GA15220@coredump.intra.peff.net","threadId":"43084","inReplyTo":"45496432.80503@shadowen.org","subject":"[PATCH] git-pickaxe: look for files relative to current path","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-11-02T07:22:49Z","receivedAt":"2006-11-02T07:22:49Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"\nSigned-off-by: Jeff King <peff@peff.net>\n---\nAndy Whitcroft writes:\n> We seem to have a difference in the handling of relative filenames\n> within a repository between git blame and git pickaxe.  Specifically git\n> pickaxe seems to always require names as if it were run in the top of\n> the project:\n\nThis simple patch seems to fix it (but is not extensively tested).\n\n builtin-pickaxe.c |   15 +++++++++++----\n 1 files changed, 11 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-pickaxe.c b/builtin-pickaxe.c\nindex c9405e9..3e76258 100644\n--- a/builtin-pickaxe.c\n+++ b/builtin-pickaxe.c\n@@ -1413,6 +1413,13 @@ static void sanity_check_refcnt(struct s\n \t}\n }\n \n+static const char *add_prefix(const char *prefix, const char *path)\n+{\n+\tif (!prefix || !prefix[0])\n+\t\treturn path;\n+\treturn prefix_path(prefix, strlen(prefix), path);\n+}\n+\n static int has_path_in_work_tree(const char *path)\n {\n \tstruct stat st;\n@@ -1548,7 +1555,7 @@ int cmd_pickaxe(int argc, const char **a\n \t\t/* (1) */\n \t\tif (argc <= i)\n \t\t\tusage(pickaxe_usage);\n-\t\tpath = argv[i];\n+\t\tpath = add_prefix(prefix, argv[i]);\n \t\tif (i + 1 == argc - 1) {\n \t\t\tif (unk != 1)\n \t\t\t\tusage(pickaxe_usage);\n@@ -1566,13 +1573,13 @@ int cmd_pickaxe(int argc, const char **a\n \t\tif (seen_dashdash) {\n \t\t\tif (seen_dashdash + 1 != argc - 1)\n \t\t\t\tusage(pickaxe_usage);\n-\t\t\tpath = argv[seen_dashdash + 1];\n+\t\t\tpath = add_prefix(prefix, argv[seen_dashdash + 1]);\n \t\t\tfor (j = i; j < seen_dashdash; j++)\n \t\t\t\targv[unk++] = argv[j];\n \t\t}\n \t\telse {\n \t\t\t/* (3) */\n-\t\t\tpath = argv[i];\n+\t\t\tpath = add_prefix(prefix, argv[i]);\n \t\t\tif (i + 1 == argc - 1) {\n \t\t\t\tfinal_commit_name = argv[i + 1];\n \n@@ -1580,7 +1587,7 @@ int cmd_pickaxe(int argc, const char **a\n \t\t\t\t * old-style\n \t\t\t\t */\n \t\t\t\tif (unk == 1 && !has_path_in_work_tree(path)) {\n-\t\t\t\t\tpath = argv[i + 1];\n+\t\t\t\t\tpath = add_prefix(prefix, argv[i + 1]);\n \t\t\t\t\tfinal_commit_name = argv[i];\n \t\t\t\t}\n \t\t\t}\n-- \n"}]}