Re: [PATCH] git-archive: document CWD effect

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: rene.scharfe
Date: Wednesday, April 11, 2007 - 1:36 pm

Junio C Hamano schrieb:

Well, I can't argue against that, as I don't have any numbers.  But I
can understand this expectation a bit ("archive HEAD!" -- "here is an
ear" might be confusing ;).


Hmm, switching the feature's default mode around instead of cutting it
off completely might be a good idea.  Something like this?  Unlike the
current implementation, it always writes the full path from the repo
root for each file.

René


diff --git a/builtin-archive.c b/builtin-archive.c
index 7f4e409..efa8679 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -128,18 +128,6 @@ void parse_treeish_arg(const char **argv, struct archiver_args *ar_args,
 	if (tree == NULL)
 		die("not a tree object");
 
-	if (prefix) {
-		unsigned char tree_sha1[20];
-		unsigned int mode;
-		int err;
-
-		err = get_tree_entry(tree->object.sha1, prefix,
-				     tree_sha1, &mode);
-		if (err || !S_ISDIR(mode))
-			die("current working directory is untracked");
-
-		tree = parse_tree_indirect(tree_sha1);
-	}
 	ar_args->tree = tree;
 	ar_args->commit_sha1 = commit_sha1;
 	ar_args->time = archive_time;
@@ -241,6 +229,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
 	struct archiver ar;
 	int tree_idx;
 	const char *remote = NULL;
+	const char **pathspec;
 
 	remote = extract_remote_arg(&argc, argv);
 	if (remote)
@@ -255,7 +244,11 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
 
 	argv += tree_idx;
 	parse_treeish_arg(argv, &ar.args, prefix);
-	parse_pathspec_arg(argv + 1, &ar.args);
+
+	pathspec = argv + 1;
+	if (*pathspec && prefix)
+		pathspec = get_pathspec(prefix, pathspec);
+	parse_pathspec_arg(pathspec, &ar.args);
 
 	return ar.write_archive(&ar.args);
 }
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
bug in git-archive?, Nick Williams, (Sat Mar 3, 9:07 am)
Re: bug in git-archive?, Johannes Schindelin, (Sat Mar 3, 9:09 am)
[PATCH] git-archive: document CWD effect, rene.scharfe, (Sun Apr 8, 5:28 am)
Re: [PATCH] git-archive: document CWD effect, Junio C Hamano, (Sun Apr 8, 4:21 pm)
Re: [PATCH] git-archive: document CWD effect, rene.scharfe, (Mon Apr 9, 8:04 am)
Re: [PATCH] git-archive: document CWD effect, Andy Parkins, (Mon Apr 9, 1:37 pm)
Re: [PATCH] git-archive: document CWD effect, rene.scharfe, (Tue Apr 10, 7:24 am)
Re: [PATCH] git-archive: document CWD effect, Junio C Hamano, (Tue Apr 10, 2:49 pm)
Re: [PATCH] git-archive: document CWD effect, rene.scharfe, (Wed Apr 11, 1:36 pm)