]> git.ipfire.org Git - thirdparty/git.git/blobdiff - setup.c
Add script for importing bits-and-pieces to Git.
[thirdparty/git.git] / setup.c
diff --git a/setup.c b/setup.c
index ebd60de9ce5b52f348819a6a390c15b8dc08d2ff..e3781b656d77be94e04c5229e6a190c5fc496490 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -81,7 +81,7 @@ void verify_filename(const char *prefix, const char *arg)
        if (errno == ENOENT)
                die("ambiguous argument '%s': unknown revision or path not in the working tree.\n"
                    "Use '--' to separate paths from revisions", arg);
-       die("'%s': %s", arg, strerror(errno));
+       die_errno("failed to stat '%s'", arg);
 }
 
 /*
@@ -103,7 +103,7 @@ void verify_non_filename(const char *prefix, const char *arg)
                die("ambiguous argument '%s': both revision and filename\n"
                    "Use '--' to separate filenames from revisions", arg);
        if (errno != ENOENT && errno != ENOTDIR)
-               die("'%s': %s", arg, strerror(errno));
+               die_errno("failed to stat '%s'", arg);
 }
 
 const char **get_pathspec(const char *prefix, const char **pathspec)
@@ -257,7 +257,7 @@ const char *read_gitfile_gently(const char *path)
                return NULL;
        fd = open(path, O_RDONLY);
        if (fd < 0)
-               die("Error opening %s: %s", path, strerror(errno));
+               die_errno("Error opening '%s'", path);
        buf = xmalloc(st.st_size + 1);
        len = read_in_full(fd, buf, st.st_size);
        close(fd);
@@ -327,7 +327,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
                                return NULL;
                        set_git_dir(make_absolute_path(gitdirenv));
                        if (chdir(work_tree_env) < 0)
-                               die ("Could not chdir to %s", work_tree_env);
+                               die_errno ("Could not chdir to '%s'", work_tree_env);
                        strcat(buffer, "/");
                        return retval;
                }
@@ -339,7 +339,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
        }
 
        if (!getcwd(cwd, sizeof(cwd)-1))
-               die("Unable to read current working directory");
+               die_errno("Unable to read current working directory");
 
        ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);
        if (ceil_offset < 0 && has_dos_drive_prefix(cwd))
@@ -382,14 +382,14 @@ const char *setup_git_directory_gently(int *nongit_ok)
                if (offset <= ceil_offset) {
                        if (nongit_ok) {
                                if (chdir(cwd))
-                                       die("Cannot come back to cwd");
+                                       die_errno("Cannot come back to cwd");
                                *nongit_ok = 1;
                                return NULL;
                        }
                        die("Not a git repository (or any of the parent directories): %s", DEFAULT_GIT_DIR_ENVIRONMENT);
                }
                if (chdir(".."))
-                       die("Cannot change to %s/..: %s", cwd, strerror(errno));
+                       die_errno("Cannot change to '%s/..'", cwd);
        }
 
        inside_git_dir = 0;
@@ -493,10 +493,10 @@ const char *setup_git_directory(void)
                static char buffer[PATH_MAX + 1];
                char *rel;
                if (retval && chdir(retval))
-                       die ("Could not jump back into original cwd");
+                       die_errno ("Could not jump back into original cwd");
                rel = get_relative_cwd(buffer, PATH_MAX, get_git_work_tree());
                if (rel && *rel && chdir(get_git_work_tree()))
-                       die ("Could not jump to working directory");
+                       die_errno ("Could not jump to working directory");
                return rel && *rel ? strcat(rel, "/") : NULL;
        }