Skip to contentSkip to conversation

Minor git-archive bug

PATCH In review Jeff Garzik 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

"git-archive --list" requires a git repository. Certainly listing the archive formats doesn't /really/ require such things.

Jeff

#1 lore raw

PATCH 1/1 Revert "builtin-archive: use RUN_SETUP"

Commit 64edf4b2 cleaned up the initialization of git-archive, at the cost of 'git-archive --list' now requiring a git repo. This patch reverts the cleanup and documents the requirement for this particular dirtyness in a test.

---

Quoted 2 lines · Jeff Garzik

"git-archive --list" requires a git repository. Certainly listing the archive formats doesn't /really/ require such things.

 builtin-archive.c   |    2 ++
 git.c               |    2 +-
 t/t5000-tar-tree.sh |    4 ++++
 3 files changed, 7 insertions(+), 1 deletions(-)
builtin-archive.c +2 -0
index 2fae885..8ea6cb1 100644
@@ -252,6 +252,8 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
 
 	memset(&ar, 0, sizeof(ar));
 	tree_idx = parse_archive_args(argc, argv, &ar);
+	if (prefix == NULL)
+		prefix = setup_git_directory();
 
 	argv += tree_idx;
 	parse_treeish_arg(argv, &ar.args, prefix);
git.c +1 -1
index 5b1bc2a..33dd4d3 100644
@@ -226,7 +226,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
 		{ "add", cmd_add, RUN_SETUP | NOT_BARE },
 		{ "annotate", cmd_annotate, USE_PAGER },
 		{ "apply", cmd_apply },
-		{ "archive", cmd_archive, RUN_SETUP },
+		{ "archive", cmd_archive },
 		{ "blame", cmd_blame, RUN_SETUP },
 		{ "branch", cmd_branch, RUN_SETUP },
 		{ "bundle", cmd_bundle },
t/t5000-tar-tree.sh +4 -0
index ac835fe..b4359df 100755
@@ -130,4 +130,8 @@ test_expect_success \
     'validate file contents with prefix' \
     'diff -r a e/prefix/a'
 
+test_expect_success \
+    'git-archive --list outside of a git repo' \
+    'GIT_DIR=some/non-existing/directory git-archive --list'
+
 test_done