From fb18a2edf7f3d1585b6330b7dde110b992d3b97c Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 26 Mar 2006 16:28:20 -0800 Subject: Fix error handling for nonexistent names When passing in a pathname pattern without the "--" separator on the command line, we verify that the pathnames in question exist. However, there were two bugs in that verification: - git-rev-parse would only check the first pathname, and silently allow any invalid subsequent pathname, whether it existed or not (which defeats the purpose of the check, and is also inconsistent with what git-rev-list actually does) - git-rev-list (and "git log" etc) would check each filename, but if the check failed, it would print the error using the first one, i.e.: [torvalds@g5 git]$ git log Makefile bad-file fatal: 'Makefile': No such file or directory instead of saying that it's 'bad-file' that doesn't exist. This fixes both bugs. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano diff --git a/rev-parse.c b/rev-parse.c index 19a5ef7..f176c56 100644 --- a/rev-parse.c +++ b/rev-parse.c @@ -172,9 +172,11 @@ int main(int argc, char **argv) struct stat st; char *arg = argv[i]; char *dotdot; - + if (as_is) { - show_file(arg); + if (show_file(arg) && as_is < 2) + if (lstat(arg, &st) < 0) + die("'%s': %s", arg, strerror(errno)); continue; } if (!strcmp(arg,"-n")) { @@ -194,7 +196,7 @@ int main(int argc, char **argv) if (*arg == '-') { if (!strcmp(arg, "--")) { - as_is = 1; + as_is = 2; /* Pass on the "--" if we show anything but files.. */ if (filter & (DO_FLAGS | DO_REVS)) show_file(arg); diff --git a/revision.c b/revision.c index 12cd052..d67718c 100644 --- a/revision.c +++ b/revision.c @@ -649,7 +649,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch /* If we didn't have a "--", all filenames must exist */ for (j = i; j < argc; j++) { if (lstat(argv[j], &st) < 0) - die("'%s': %s", arg, strerror(errno)); + die("'%s': %s", argv[j], strerror(errno)); } revs->prune_data = get_pathspec(revs->prefix, argv + i); break; -- cgit v0.10.2-6-g49f6 From 8978d043c35ad068e280dbbdc31e06524ea0ab56 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Sun, 26 Mar 2006 15:29:28 -0500 Subject: Document git-rebase behavior on conflicts. diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index b36276c..4a7e67a 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -48,6 +48,18 @@ would be: / D---E---F---G master +In case of conflict, git-rebase will stop at the first problematic commit +and leave conflict markers in the tree. After resolving the conflict manually +and updating the index with the desired resolution, you can continue the +rebasing process with + + git am --resolved --3way + +Alternatively, you can undo the git-rebase with + + git reset --hard ORIG_HEAD + rm -r .dotest + OPTIONS ------- :: -- cgit v0.10.2-6-g49f6 From b0a3de42316a4e8f1d561cbe12b7bb282631a0d6 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 26 Mar 2006 16:59:52 +0200 Subject: Optionally do not list empty directories in git-ls-files --others Without the --directory flag, git-ls-files wouldn't ever list directories, producing no output for empty directories, which is good since they cannot be added and they bear no content, even untracked one (if Git ever starts tracking directories on their own, this should obviously change since the content notion will change). With the --directory flag however, git-ls-files would list even empty directories. This may be good in some situations but sometimes you want to prevent that. This patch adds a --no-empty-directory option which makes git-ls-files omit empty directories. Signed-off-by: Petr Baudis diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index e813f84..980c5c9 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -52,6 +52,9 @@ OPTIONS If a whole directory is classified as "other", show just its name (with a trailing slash) and not its whole contents. +--no-empty-directory:: + Do not list empty directories. Has no effect without --directory. + -u|--unmerged:: Show unmerged files in the output (forces --stage) diff --git a/ls-files.c b/ls-files.c index e42119c..83b0a3b 100644 --- a/ls-files.c +++ b/ls-files.c @@ -20,6 +20,7 @@ static int show_unmerged = 0; static int show_modified = 0; static int show_killed = 0; static int show_other_directories = 0; +static int hide_empty_directories = 0; static int show_valid_bit = 0; static int line_terminator = '\n'; @@ -258,11 +259,12 @@ static int dir_exists(const char *dirname, int len) * Also, we ignore the name ".git" (even if it is not a directory). * That likely will not change. */ -static void read_directory(const char *path, const char *base, int baselen) +static int read_directory(const char *path, const char *base, int baselen) { - DIR *dir = opendir(path); + DIR *fdir = opendir(path); + int contents = 0; - if (dir) { + if (fdir) { int exclude_stk; struct dirent *de; char fullname[MAXPATHLEN + 1]; @@ -270,7 +272,7 @@ static void read_directory(const char *path, const char *base, int baselen) exclude_stk = push_exclude_per_directory(base, baselen); - while ((de = readdir(dir)) != NULL) { + while ((de = readdir(fdir)) != NULL) { int len; if ((de->d_name[0] == '.') && @@ -288,6 +290,7 @@ static void read_directory(const char *path, const char *base, int baselen) switch (DTYPE(de)) { struct stat st; + int subdir, rewind_base; default: continue; case DT_UNKNOWN: @@ -301,22 +304,32 @@ static void read_directory(const char *path, const char *base, int baselen) case DT_DIR: memcpy(fullname + baselen + len, "/", 2); len++; + rewind_base = nr_dir; + subdir = read_directory(fullname, fullname, + baselen + len); if (show_other_directories && - !dir_exists(fullname, baselen + len)) + (subdir || !hide_empty_directories) && + !dir_exists(fullname, baselen + len)) { + // Rewind the read subdirectory + while (nr_dir > rewind_base) + free(dir[--nr_dir]); break; - read_directory(fullname, fullname, - baselen + len); + } + contents += subdir; continue; case DT_REG: case DT_LNK: break; } add_name(fullname, baselen + len); + contents++; } - closedir(dir); + closedir(fdir); pop_exclude_per_directory(exclude_stk); } + + return contents; } static int cmp_name(const void *p1, const void *p2) @@ -696,6 +709,10 @@ int main(int argc, const char **argv) show_other_directories = 1; continue; } + if (!strcmp(arg, "--no-empty-directory")) { + hide_empty_directories = 1; + continue; + } if (!strcmp(arg, "-u") || !strcmp(arg, "--unmerged")) { /* There's no point in showing unmerged unless * you also show the stage information. -- cgit v0.10.2-6-g49f6