mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 13:53:09 +02:00
sch2fig/git-file.c: keep the repo root search simple
I originally planned to attach the (deleted) tail after splitting the path of existing things into path_to_repo and path_in_repo, but it's easier if we just do the search on the combined path. This means that stat() will fail while we're in the deleted part of the path.
This commit is contained in:
parent
f4745953b5
commit
590724e3bb
@ -210,27 +210,20 @@ static char *canonical_path_into_repo(const char *repo_dir, const char *path)
|
|||||||
if (verbose > 1)
|
if (verbose > 1)
|
||||||
fprintf(stderr, "full object path \"%s\"\n", tmp);
|
fprintf(stderr, "full object path \"%s\"\n", tmp);
|
||||||
|
|
||||||
/* find which part of out path is inside the repo */
|
/* find which part of our path is inside the repo */
|
||||||
|
|
||||||
end = tail = strchr(tmp, 0);
|
end = tail = strchr(tmp, 0);
|
||||||
while (1) {
|
while (1) {
|
||||||
if (verbose > 2)
|
if (verbose > 2)
|
||||||
fprintf(stderr, "trying \"%s\" tail \"%s\"\n",
|
fprintf(stderr, "trying \"%s\" tail \"%s\"\n",
|
||||||
tmp, tail);
|
tmp, tail);
|
||||||
/*
|
|
||||||
* This should never fail, unless someone has been changing
|
|
||||||
* things while we were searching.
|
|
||||||
*/
|
|
||||||
if (stat(tmp, &path_st) < 0) {
|
|
||||||
perror(tmp);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path_st.st_dev == repo_st.st_dev &&
|
if (stat(tmp, &path_st) == 0 &&
|
||||||
|
path_st.st_dev == repo_st.st_dev &&
|
||||||
path_st.st_ino == repo_st.st_ino)
|
path_st.st_ino == repo_st.st_ino)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* another "this cannot happen" problem */
|
/* "this cannot happen" */
|
||||||
if (tail == tmp) {
|
if (tail == tmp) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"divergent paths:\nrepo \"%s\"\nobject \"%s\"\n",
|
"divergent paths:\nrepo \"%s\"\nobject \"%s\"\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user