sha1_file: rename LOOKUP_REPLACE_OBJECT
[gitweb.git] / remote-testsvn.c
index f599c372c64dd8930f9640e9503f73c5edaff49c..50404ef3438f37ae33e3590f1e7205581087f75a 100644 (file)
@@ -124,10 +124,8 @@ static int note2mark_cb(const unsigned char *object_sha1,
 static void regenerate_marks(void)
 {
        int ret;
-       FILE *marksfile = fopen(marksfilename, "w+");
+       FILE *marksfile = xfopen(marksfilename, "w+");
 
-       if (!marksfile)
-               die_errno("Couldn't create mark file %s.", marksfilename);
        ret = for_each_note(NULL, 0, note2mark_cb, marksfile);
        if (ret)
                die("Regeneration of marks failed, returned %d.", ret);
@@ -148,13 +146,11 @@ static void check_or_regenerate_marks(int latestrev)
        marksfile = fopen(marksfilename, "r");
        if (!marksfile) {
                regenerate_marks();
-               marksfile = fopen(marksfilename, "r");
-               if (!marksfile)
-                       die_errno("cannot read marks file %s!", marksfilename);
+               marksfile = xfopen(marksfilename, "r");
                fclose(marksfile);
        } else {
                strbuf_addf(&sb, ":%d ", latestrev);
-               while (strbuf_getline(&line, marksfile, '\n') != EOF) {
+               while (strbuf_getline_lf(&line, marksfile) != EOF) {
                        if (starts_with(line.buf, sb.buf)) {
                                found++;
                                break;
@@ -284,7 +280,7 @@ static int do_command(struct strbuf *line)
        return 0;
 }
 
-int main(int argc, char **argv)
+int cmd_main(int argc, const char **argv)
 {
        struct strbuf buf = STRBUF_INIT, url_sb = STRBUF_INIT,
                        private_ref_sb = STRBUF_INIT, marksfilename_sb = STRBUF_INIT,
@@ -292,7 +288,6 @@ int main(int argc, char **argv)
        static struct remote *remote;
        const char *url_in;
 
-       git_extract_argv0_path(argv[0]);
        setup_git_directory();
        if (argc < 2 || argc > 3) {
                usage("git-remote-svn <remote-name> [<url>]");
@@ -322,7 +317,7 @@ int main(int argc, char **argv)
        marksfilename = marksfilename_sb.buf;
 
        while (1) {
-               if (strbuf_getline(&buf, stdin, '\n') == EOF) {
+               if (strbuf_getline_lf(&buf, stdin) == EOF) {
                        if (ferror(stdin))
                                die("Error reading command stream");
                        else