Skip to content

Commit

Permalink
Make the rest of commands work from a subdirectory.
Browse files Browse the repository at this point in the history
These commands are converted to run from a subdirectory.

    commit-tree convert-objects merge-base merge-index mktag
    pack-objects pack-redundant prune-packed read-tree tar-tree
    unpack-file unpack-objects update-server-info write-tree

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Nov 29, 2005
1 parent 5a32771 commit 53228a5
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ int main(int argc, char **argv)
if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0)
usage(commit_tree_usage);

setup_git_directory();

check_valid(tree_sha1, "tree");
for (i = 2; i < argc; i += 2) {
char *a, *b;
Expand Down
2 changes: 2 additions & 0 deletions convert-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ int main(int argc, char **argv)
unsigned char sha1[20];
struct entry *entry;

setup_git_directory();

if (argc != 2 || get_sha1(argv[1], sha1))
usage("git-convert-objects <sha1>");

Expand Down
2 changes: 2 additions & 0 deletions merge-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ int main(int argc, char **argv)
struct commit *rev1, *rev2;
unsigned char rev1key[20], rev2key[20];

setup_git_directory();

while (1 < argc && argv[1][0] == '-') {
char *arg = argv[1];
if (!strcmp(arg, "-a") || !strcmp(arg, "--all"))
Expand Down
1 change: 1 addition & 0 deletions merge-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ int main(int argc, char **argv)
if (argc < 3)
usage("git-merge-index [-o] [-q] <merge-program> (-a | <filename>*)");

setup_git_directory();
read_cache();

i = 1;
Expand Down
2 changes: 2 additions & 0 deletions mktag.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ int main(int argc, char **argv)
if (argc != 1)
usage("cat <signaturefile> | git-mktag");

setup_git_directory();

// Read the signature
size = 0;
for (;;) {
Expand Down
2 changes: 2 additions & 0 deletions pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ int main(int argc, char **argv)
struct object_entry **list;
int i;

setup_git_directory();

for (i = 1; i < argc; i++) {
const char *arg = argv[i];

Expand Down
2 changes: 2 additions & 0 deletions pack-redundant.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,8 @@ int main(int argc, char **argv)
unsigned char *sha1;
char buf[42]; /* 40 byte sha1 + \n + \0 */

setup_git_directory();

for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if(!strcmp(arg, "--")) {
Expand Down
2 changes: 2 additions & 0 deletions prune-packed.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ int main(int argc, char **argv)
{
int i;

setup_git_directory();

for (i = 1; i < argc; i++) {
const char *arg = argv[i];

Expand Down
2 changes: 2 additions & 0 deletions read-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ int main(int argc, char **argv)
unsigned char sha1[20];
merge_fn_t fn = NULL;

setup_git_directory();

newfd = hold_index_file_for_update(&cache_file, get_index_file());
if (newfd < 0)
die("unable to create new cachefile");
Expand Down
2 changes: 2 additions & 0 deletions tar-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ int main(int argc, char **argv)
void *buffer;
unsigned long size;

setup_git_directory();

switch (argc) {
case 3:
basedir = argv[2];
Expand Down
2 changes: 2 additions & 0 deletions unpack-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ int main(int argc, char **argv)
if (argc != 2 || get_sha1(argv[1], sha1))
usage("git-unpack-file <sha1>");

setup_git_directory();

puts(create_temp_file(sha1));
return 0;
}
2 changes: 2 additions & 0 deletions unpack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ int main(int argc, char **argv)
int i;
unsigned char sha1[20];

setup_git_directory();

for (i = 1 ; i < argc; i++) {
const char *arg = argv[i];

Expand Down
2 changes: 2 additions & 0 deletions update-server-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ int main(int ac, char **av)
if (i != ac)
usage(update_server_info_usage);

setup_git_directory();

return !!update_server_info(force);
}
5 changes: 4 additions & 1 deletion write-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ static int write_tree(struct cache_entry **cachep, int maxentries, const char *b
int main(int argc, char **argv)
{
int i, funny;
int entries = read_cache();
int entries;
unsigned char sha1[20];

setup_git_directory();

entries = read_cache();
if (argc == 2) {
if (!strcmp(argv[1], "--missing-ok"))
missing_ok = 1;
Expand Down

0 comments on commit 53228a5

Please sign in to comment.