summaryrefslogtreecommitdiff
path: root/diff-cache.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-05 16:31:09 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-05 16:31:09 (GMT)
commit160c8433d904340615bafd7757355618e99e20d5 (patch)
tree30d6a5a3a558929509c6962549fb30a851ac5648 /diff-cache.c
parent8ae0a8c514dc492de8aadf3ca6bb4ad55e33960e (diff)
downloadgit-160c8433d904340615bafd7757355618e99e20d5.zip
git-160c8433d904340615bafd7757355618e99e20d5.tar.gz
git-160c8433d904340615bafd7757355618e99e20d5.tar.bz2
git-diff-cache: add "-m" flag to match all non-checked-out files with the index.
This allows you to work with a directory tree that isn't fully populated, without making diff-cache say that all the files are gone.
Diffstat (limited to 'diff-cache.c')
-rw-r--r--diff-cache.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/diff-cache.c b/diff-cache.c
index 94c5f66..ef522cd 100644
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -3,6 +3,7 @@
static int cached_only = 0;
static int generate_patch = 0;
+static int match_nonexisting = 0;
static int line_termination = '\n';
/* A file entry went away or appeared */
@@ -24,8 +25,14 @@ static int get_stat_data(struct cache_entry *ce, unsigned char **sha1p, unsigned
static unsigned char no_sha1[20];
int changed;
struct stat st;
- if (lstat(ce->name, &st) < 0)
+ if (lstat(ce->name, &st) < 0) {
+ if (errno == ENOENT && match_nonexisting) {
+ *sha1p = sha1;
+ *modep = mode;
+ return 0;
+ }
return -1;
+ }
changed = cache_match_stat(ce, &st);
if (changed) {
mode = create_ce_mode(st.st_mode);
@@ -143,7 +150,7 @@ static void mark_merge_entries(void)
}
static char *diff_cache_usage =
-"diff-cache [-r] [-z] [-p] [--cached] <tree sha1>";
+"diff-cache [-r] [-z] [-p] [-i] [--cached] <tree sha1>";
int main(int argc, char **argv)
{
@@ -168,6 +175,10 @@ int main(int argc, char **argv)
line_termination = '\0';
continue;
}
+ if (!strcmp(arg, "-m")) {
+ match_nonexisting = 1;
+ continue;
+ }
if (!strcmp(arg, "--cached")) {
cached_only = 1;
continue;