All of lore.kernel.org
 help / color / mirror / Atom feed
* git pickaxe -- problems with relative filenames
@ 2006-11-02  3:21 Andy Whitcroft
  2006-11-02  7:22 ` [PATCH] git-pickaxe: look for files relative to current path Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Whitcroft @ 2006-11-02  3:21 UTC (permalink / raw)
  To: Git Mailing List, Junio C Hamano

We seem to have a difference in the handling of relative filenames
within a repository between git blame and git pickaxe.  Specifically git
pickaxe seems to always require names as if it were run in the top of
the project:

apw@pinky$ pwd
/home/apw/git/git/Documentation
apw@pinky$ git blame git.txt | head -2
7984eabe (Sebastian Kuzminsky 2005-05-19 10:24:54 -0600   1) git(7)
2cf565c5 (David Greaves       2005-05-10 22:32:30 +0100   2) ======
apw@pinky$ git pickaxe git.txt | head -2
fatal: cannot stat path git.txt: No such file or directory
apw@pinky$ git pickaxe Documentation/git.txt | head -2
7984eabe (Sebastian Kuzminsky 2005-05-19 10:24:54 -0600   1) git(7)
2cf565c5 (David Greaves       2005-05-10 22:32:30 +0100   2) ======

This seems inconsistent? Is this expected behaviour?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] git-pickaxe: look for files relative to current path
  2006-11-02  3:21 git pickaxe -- problems with relative filenames Andy Whitcroft
@ 2006-11-02  7:22 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2006-11-02  7:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Andy Whitcroft


Signed-off-by: Jeff King <peff@peff.net>
---
Andy Whitcroft writes:
> We seem to have a difference in the handling of relative filenames
> within a repository between git blame and git pickaxe.  Specifically git
> pickaxe seems to always require names as if it were run in the top of
> the project:

This simple patch seems to fix it (but is not extensively tested).

 builtin-pickaxe.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/builtin-pickaxe.c b/builtin-pickaxe.c
index c9405e9..3e76258 100644
--- a/builtin-pickaxe.c
+++ b/builtin-pickaxe.c
@@ -1413,6 +1413,13 @@ static void sanity_check_refcnt(struct s
 	}
 }
 
+static const char *add_prefix(const char *prefix, const char *path)
+{
+	if (!prefix || !prefix[0])
+		return path;
+	return prefix_path(prefix, strlen(prefix), path);
+}
+
 static int has_path_in_work_tree(const char *path)
 {
 	struct stat st;
@@ -1548,7 +1555,7 @@ int cmd_pickaxe(int argc, const char **a
 		/* (1) */
 		if (argc <= i)
 			usage(pickaxe_usage);
-		path = argv[i];
+		path = add_prefix(prefix, argv[i]);
 		if (i + 1 == argc - 1) {
 			if (unk != 1)
 				usage(pickaxe_usage);
@@ -1566,13 +1573,13 @@ int cmd_pickaxe(int argc, const char **a
 		if (seen_dashdash) {
 			if (seen_dashdash + 1 != argc - 1)
 				usage(pickaxe_usage);
-			path = argv[seen_dashdash + 1];
+			path = add_prefix(prefix, argv[seen_dashdash + 1]);
 			for (j = i; j < seen_dashdash; j++)
 				argv[unk++] = argv[j];
 		}
 		else {
 			/* (3) */
-			path = argv[i];
+			path = add_prefix(prefix, argv[i]);
 			if (i + 1 == argc - 1) {
 				final_commit_name = argv[i + 1];
 
@@ -1580,7 +1587,7 @@ int cmd_pickaxe(int argc, const char **a
 				 * old-style
 				 */
 				if (unk == 1 && !has_path_in_work_tree(path)) {
-					path = argv[i + 1];
+					path = add_prefix(prefix, argv[i + 1]);
 					final_commit_name = argv[i];
 				}
 			}
-- 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-11-02  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-02  3:21 git pickaxe -- problems with relative filenames Andy Whitcroft
2006-11-02  7:22 ` [PATCH] git-pickaxe: look for files relative to current path Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.