Merge branch 'tojunio' of http://locke.catalyst.net.nz/git/git-martinlanghoff into...
authorJunio C Hamano <junkio@cox.net>
Tue, 9 May 2006 19:25:21 +0000 (12:25 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 9 May 2006 19:25:21 +0000 (12:25 -0700)
* 'tojunio' of http://locke.catalyst.net.nz/git/git-martinlanghoff:
  Change to allow subdir updates from Eclipse
  Many fixes for most operations in Eclipse.
  Added logged warnings for CVS error returns
  cvsserver: use git-rev-list instead of git-log
  git-cvsexportcommit: Add -f(orce) and -m(essage prefix) flags, small cleanups.

22 files changed:
Documentation/core-tutorial.txt
Documentation/git-repo-config.txt
Documentation/git-rev-list.txt
builtin-diff.c
cat-file.c
commit-tree.c
config.c
convert-objects.c
describe.c
diff.c
git-clone.sh
git-repack.sh
ls-tree.c
merge-base.c
merge-tree.c
read-tree.c
revision.c
ssh-upload.c
t/t5700-clone-reference.sh [new file with mode: 0755]
tar-tree.c
unpack-file.c
update-ref.c

index 4211c81..d1360ec 100644 (file)
@@ -971,7 +971,7 @@ $ git show-branch --topo-order master mybranch
 The first two lines indicate that it is showing the two branches
 and the first line of the commit log message from their
 top-of-the-tree commits, you are currently on `master` branch
-(notice the asterisk `*` character), and the first column for
+(notice the asterisk `\*` character), and the first column for
 the later output lines is used to show commits contained in the
 `master` branch, and the second column for the `mybranch`
 branch. Three commits are shown along with their log messages.
index fd44f62..660c18f 100644 (file)
@@ -23,10 +23,11 @@ You can query/set/replace/unset options with this command. The name is
 actually the section and the key separated by a dot, and the value will be
 escaped.
 
-If you want to set/unset an option which can occur on multiple lines, you
-should provide a POSIX regex for the value. If you want to handle the lines
-*not* matching the regex, just prepend a single exclamation mark in front
-(see EXAMPLES).
+If you want to set/unset an option which can occur on multiple
+lines, a POSIX regexp `value_regex` needs to be given.  Only the
+existing values that match the regexp are updated or unset.  If
+you want to handle the lines that do *not* match the regex, just
+prepend a single exclamation mark in front (see EXAMPLES).
 
 The type specifier can be either '--int' or '--bool', which will make
 'git-repo-config' ensure that the variable(s) are of the given type and
index 8255ae1..ad6d14c 100644 (file)
@@ -68,9 +68,10 @@ OPTIONS
 --bisect::
        Limit output to the one commit object which is roughly halfway
        between the included and excluded commits. Thus, if 'git-rev-list
-       --bisect foo ^bar ^baz' outputs 'midpoint', the output
-       of 'git-rev-list foo ^midpoint' and 'git-rev-list midpoint
-       ^bar ^baz' would be of roughly the same length. Finding the change
+       --bisect foo {caret}bar {caret}baz' outputs 'midpoint', the output
+       of 'git-rev-list foo {caret}midpoint' and 'git-rev-list midpoint
+       {caret}bar {caret}baz' would be of roughly the same length.
+       Finding the change
        which introduces a regression is thus reduced to a binary search:
        repeatedly generate and test new 'midpoint's until the commit chain
        is of length one.
index 636edbf..d3ac581 100644 (file)
@@ -84,8 +84,7 @@ static void stuff_change(struct diff_options *opt,
 
        if (opt->reverse_diff) {
                unsigned tmp;
-               const
-                       const unsigned char *tmp_u;
+               const unsigned char *tmp_u;
                const char *tmp_c;
                tmp = old_mode; old_mode = new_mode; new_mode = tmp;
                tmp_u = old_sha1; old_sha1 = new_sha1; new_sha1 = tmp_u;
index 628f6ca..7413fee 100644 (file)
@@ -103,8 +103,10 @@ int main(int argc, char **argv)
 
        setup_git_directory();
        git_config(git_default_config);
-       if (argc != 3 || get_sha1(argv[2], sha1))
+       if (argc != 3)
                usage("git-cat-file [-t|-s|-e|-p|<type>] <sha1>");
+       if (get_sha1(argv[2], sha1))
+               die("Not a valid object name %s", argv[2]);
 
        opt = 0;
        if ( argv[1][0] == '-' ) {
@@ -133,8 +135,7 @@ int main(int argc, char **argv)
                return !has_sha1_file(sha1);
 
        case 'p':
-               if (get_sha1(argv[2], sha1) ||
-                   sha1_object_info(sha1, type, NULL))
+               if (sha1_object_info(sha1, type, NULL))
                        die("Not a valid object name %s", argv[2]);
 
                /* custom pretty-print here */
index bad72e8..0320036 100644 (file)
@@ -91,15 +91,19 @@ int main(int argc, char **argv)
 
        git_config(git_default_config);
 
-       if (argc < 2 || get_sha1(argv[1], tree_sha1) < 0)
+       if (argc < 2)
                usage(commit_tree_usage);
+       if (get_sha1(argv[1], tree_sha1))
+               die("Not a valid object name %s", argv[1]);
 
        check_valid(tree_sha1, tree_type);
        for (i = 2; i < argc; i += 2) {
                char *a, *b;
                a = argv[i]; b = argv[i+1];
-               if (!b || strcmp(a, "-p") || get_sha1(b, parent_sha1[parents]))
+               if (!b || strcmp(a, "-p"))
                        usage(commit_tree_usage);
+               if (get_sha1(b, parent_sha1[parents]))
+                       die("Not a valid object name %s", b);
                check_valid(parent_sha1[parents], commit_type);
                if (new_parent(parents))
                        parents++;
index 41066e4..0f518c9 100644 (file)
--- a/config.c
+++ b/config.c
@@ -422,7 +422,7 @@ int git_config_set_multivar(const char* key, const char* value,
        const char* value_regex, int multi_replace)
 {
        int i;
-       int fd, in_fd;
+       int fd = -1, in_fd;
        int ret;
        char* config_filename = strdup(git_path("config"));
        char* lock_file = strdup(git_path("config.lock"));
@@ -480,15 +480,11 @@ int git_config_set_multivar(const char* key, const char* value,
                if ( ENOENT != errno ) {
                        error("opening %s: %s", config_filename,
                              strerror(errno));
-                       close(fd);
-                       unlink(lock_file);
                        ret = 3; /* same as "invalid config file" */
                        goto out_free;
                }
                /* if nothing to unset, error out */
                if (value == NULL) {
-                       close(fd);
-                       unlink(lock_file);
                        ret = 5;
                        goto out_free;
                }
@@ -551,8 +547,6 @@ int git_config_set_multivar(const char* key, const char* value,
                /* if nothing to unset, or too many matches, error out */
                if ((store.seen == 0 && value == NULL) ||
                                (store.seen > 1 && multi_replace == 0)) {
-                       close(fd);
-                       unlink(lock_file);
                        ret = 5;
                        goto out_free;
                }
@@ -601,8 +595,6 @@ int git_config_set_multivar(const char* key, const char* value,
                unlink(config_filename);
        }
 
-       close(fd);
-
        if (rename(lock_file, config_filename) < 0) {
                fprintf(stderr, "Could not rename the lock file?\n");
                ret = 4;
@@ -612,10 +604,14 @@ int git_config_set_multivar(const char* key, const char* value,
        ret = 0;
 
 out_free:
+       if (0 <= fd)
+               close(fd);
        if (config_filename)
                free(config_filename);
-       if (lock_file)
+       if (lock_file) {
+               unlink(lock_file);
                free(lock_file);
+       }
        return ret;
 }
 
index 12aacef..a67d6b4 100644 (file)
@@ -321,8 +321,10 @@ int main(int argc, char **argv)
 
        setup_git_directory();
 
-       if (argc != 2 || get_sha1(argv[1], sha1))
+       if (argc != 2)
                usage("git-convert-objects <sha1>");
+       if (get_sha1(argv[1], sha1))
+               die("Not a valid object name %s", argv[1]);
 
        entry = convert_entry(sha1);
        printf("new sha1: %s\n", sha1_to_hex(entry->new_sha1));
index ff65742..8a9cd5d 100644 (file)
@@ -105,11 +105,11 @@ static void describe(char *arg, int last_one)
        static int initialized = 0;
        struct commit_name *n;
 
-       if (get_sha1(arg, sha1) < 0)
-               usage(describe_usage);
+       if (get_sha1(arg, sha1))
+               die("Not a valid object name %s", arg);
        cmit = lookup_commit_reference(sha1);
        if (!cmit)
-               usage(describe_usage);
+               die("%s is not a valid '%s' object", arg, commit_type);
 
        if (!initialized) {
                initialized = 1;
diff --git a/diff.c b/diff.c
index c845c87..5315270 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -296,7 +296,6 @@ static const char minuses[]= "--------------------------------------------------
 
 static void show_stats(struct diffstat_t* data)
 {
-       char *prefix = "";
        int i, len, add, del, total, adds = 0, dels = 0;
        int max, max_change = 0, max_len = 0;
        int total_files = data->nr;
@@ -318,6 +317,7 @@ static void show_stats(struct diffstat_t* data)
        }
 
        for (i = 0; i < data->nr; i++) {
+               char *prefix = "";
                char *name = data->files[i]->name;
                int added = data->files[i]->added;
                int deleted = data->files[i]->deleted;
index 0805168..b785247 100755 (executable)
@@ -265,7 +265,7 @@ yes,yes)
                test -f "$repo/objects/info/alternates" &&
                cat "$repo/objects/info/alternates";
                echo "$repo/objects"
-           } >"$GIT_DIR/objects/info/alternates"
+           } >>"$GIT_DIR/objects/info/alternates"
            ;;
        esac
        git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD"
index e0c9f32..4fb3f26 100755 (executable)
@@ -48,15 +48,15 @@ name=$(git-rev-list --objects --all $rev_list 2>&1 |
        exit 1
 if [ -z "$name" ]; then
        echo Nothing new to pack.
-       exit 0
-fi
-echo "Pack pack-$name created."
+else
+       echo "Pack pack-$name created."
 
-mkdir -p "$PACKDIR" || exit
+       mkdir -p "$PACKDIR" || exit
 
-mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
-mv .tmp-pack-$name.idx  "$PACKDIR/pack-$name.idx" ||
-exit
+       mv .tmp-pack-$name.pack "$PACKDIR/pack-$name.pack" &&
+       mv .tmp-pack-$name.idx  "$PACKDIR/pack-$name.idx" ||
+       exit
+fi
 
 if test "$remove_redundant" = t
 then
index e4ef200..f2b3bc1 100644 (file)
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -142,8 +142,8 @@ int main(int argc, const char **argv)
 
        if (argc < 2)
                usage(ls_tree_usage);
-       if (get_sha1(argv[1], sha1) < 0)
-               usage(ls_tree_usage);
+       if (get_sha1(argv[1], sha1))
+               die("Not a valid object name %s", argv[1]);
 
        pathspec = get_pathspec(prefix, argv + 2);
        tree = parse_tree_indirect(sha1);
index 07f5ab4..f0dc06e 100644 (file)
@@ -247,10 +247,12 @@ int main(int argc, char **argv)
                        usage(merge_base_usage);
                argc--; argv++;
        }
-       if (argc != 3 ||
-           get_sha1(argv[1], rev1key) ||
-           get_sha1(argv[2], rev2key))
+       if (argc != 3)
                usage(merge_base_usage);
+       if (get_sha1(argv[1], rev1key))
+               die("Not a valid object name %s", argv[1]);
+       if (get_sha1(argv[2], rev2key))
+               die("Not a valid object name %s", argv[2]);
        rev1 = lookup_commit_reference(rev1key);
        rev2 = lookup_commit_reference(rev2key);
        if (!rev1 || !rev2)
index cc7b5bd..9dcaab7 100644 (file)
@@ -149,7 +149,7 @@ static void *get_tree_descriptor(struct tree_desc *desc, const char *rev)
        unsigned char sha1[20];
        void *buf;
 
-       if (get_sha1(rev, sha1) < 0)
+       if (get_sha1(rev, sha1))
                die("unknown rev %s", rev);
        buf = fill_tree_descriptor(desc, sha1);
        if (!buf)
index 26f4f7e..e926e4c 100644 (file)
@@ -794,8 +794,8 @@ int main(int argc, char **argv)
                if (1 < index_only + update)
                        usage(read_tree_usage);
 
-               if (get_sha1(arg, sha1) < 0)
-                       usage(read_tree_usage);
+               if (get_sha1(arg, sha1))
+                       die("Not a valid object name %s", arg);
                if (list_tree(sha1) < 0)
                        die("failed to unpack tree object %s", arg);
                stage++;
index f8ee38e..2294b16 100644 (file)
@@ -794,7 +794,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
                        local_flags = UNINTERESTING;
                        arg++;
                }
-               if (get_sha1(arg, sha1) < 0) {
+               if (get_sha1(arg, sha1)) {
                        int j;
 
                        if (seen_dashdash || local_flags)
@@ -820,7 +820,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
        if (def && !revs->pending_objects) {
                unsigned char sha1[20];
                struct object *object;
-               if (get_sha1(def, sha1) < 0)
+               if (get_sha1(def, sha1))
                        die("bad default revision '%s'", def);
                object = get_reference(revs, def, sha1, 0);
                add_pending_object(revs, object, def);
index b675a0b..2da6661 100644 (file)
@@ -134,7 +134,7 @@ int main(int argc, char **argv)
        commit_id = argv[arg];
        url = argv[arg + 1];
        if (get_sha1(commit_id, sha1))
-               usage(ssh_push_usage);
+               die("Not a valid object name %s", commit_id);
        memcpy(hex, sha1_to_hex(sha1), sizeof(hex));
        argv[arg] = hex;
 
diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh
new file mode 100755 (executable)
index 0000000..916ee15
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
+#
+
+test_description='test clone --reference'
+. ./test-lib.sh
+
+base_dir=`pwd`
+
+test_expect_success 'preparing first repository' \
+'test_create_repo A && cd A &&
+echo first > file1 &&
+git add file1 &&
+git commit -m initial'
+
+cd "$base_dir"
+
+test_expect_success 'preparing second repository' \
+'git clone A B && cd B &&
+echo second > file2 &&
+git add file2 &&
+git commit -m addition &&
+git repack -a -d &&
+git prune'
+
+cd "$base_dir"
+
+test_expect_success 'cloning with reference' \
+'git clone -l -s --reference B A C'
+
+cd "$base_dir"
+
+test_expect_success 'existance of info/alternates' \
+'test `wc -l <C/.git/objects/info/alternates` = 2'
+
+cd "$base_dir"
+
+test_expect_success 'pulling from reference' \
+'cd C &&
+git pull ../B'
+
+cd "$base_dir"
+
+test_expect_success 'that reference gets used' \
+'cd C &&
+echo "0 objects, 0 kilobytes" > expected &&
+git count-objects > current &&
+diff expected current'
+
+cd "$base_dir"
+
+test_expect_success 'updating origin' \
+'cd A &&
+echo third > file3 &&
+git add file3 &&
+git commit -m update &&
+git repack -a -d &&
+git prune'
+
+cd "$base_dir"
+
+test_expect_success 'pulling changes from origin' \
+'cd C &&
+git pull origin'
+
+cd "$base_dir"
+
+# the 2 local objects are commit and tree from the merge
+test_expect_success 'that alternate to origin gets used' \
+'cd C &&
+echo "2 objects" > expected &&
+git count-objects | cut -d, -f1 > current &&
+diff expected current'
+
+cd "$base_dir"
+
+test_done
index fc60a90..3308736 100644 (file)
@@ -321,8 +321,8 @@ int main(int argc, char **argv)
                strbuf_append_string(&current_path, "/");
                /* FALLTHROUGH */
        case 2:
-               if (get_sha1(argv[1], sha1) < 0)
-                       usage(tar_tree_usage);
+               if (get_sha1(argv[1], sha1))
+                       die("Not a valid object name %s", argv[1]);
                break;
        default:
                usage(tar_tree_usage);
index 23a8562..ccddf1d 100644 (file)
@@ -27,8 +27,10 @@ int main(int argc, char **argv)
 {
        unsigned char sha1[20];
 
-       if (argc != 2 || get_sha1(argv[1], sha1))
+       if (argc != 2)
                usage("git-unpack-file <sha1>");
+       if (get_sha1(argv[1], sha1))
+               die("Not a valid object name %s", argv[1]);
 
        setup_git_directory();
        git_config(git_default_config);
index ba4bf51..fd48742 100644 (file)
@@ -32,10 +32,10 @@ int main(int argc, char **argv)
        refname = argv[1];
        value = argv[2];
        oldval = argv[3];
-       if (get_sha1(value, sha1) < 0)
+       if (get_sha1(value, sha1))
                die("%s: not a valid SHA1", value);
        memset(oldsha1, 0, 20);
-       if (oldval && get_sha1(oldval, oldsha1) < 0)
+       if (oldval && get_sha1(oldval, oldsha1))
                die("%s: not a valid old SHA1", oldval);
 
        path = resolve_ref(git_path("%s", refname), currsha1, !!oldval);