diff options
author | Russell Belfer <rb@github.com> | 2012-10-08 15:14:12 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-10-08 15:22:40 -0700 |
commit | dfbff793b8f39995d3a8744d6b7d75d5cc7201a0 (patch) | |
tree | 0ffa00f2e946fc65596b08b6064ac2fee25a0963 /src/diff_output.c | |
parent | 543864b677704845660085d2b2b2249cabb084a4 (diff) | |
download | libgit2-dfbff793b8f39995d3a8744d6b7d75d5cc7201a0.tar.gz |
Fix a few diff bugs with directory content
There are a few cases where diff should leave directories in
the diff list if we want to match core git, such as when the
directory contains a .git dir. That feature was lost when I
introduced some of the new submodule handling.
This restores that and then fixes a couple of related to diff
output that are triggered by having diffs with directories in
them.
Also, this adds a new flag that can be passed to diff if you
want diff output to actually include the file content of any
untracked files.
Diffstat (limited to 'src/diff_output.c')
-rw-r--r-- | src/diff_output.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/diff_output.c b/src/diff_output.c index f5f6c381e..9fee127c6 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -321,6 +321,9 @@ static int get_workdir_content( if (file->mode == GIT_FILEMODE_COMMIT) return get_workdir_sm_content(ctxt, file, map); + if (S_ISDIR(file->mode)) + return 0; + if (git_buf_joinpath(&path, wd, file->path) < 0) return -1; @@ -535,6 +538,11 @@ static int diff_patch_load( break; case GIT_DELTA_MODIFIED: break; + case GIT_DELTA_UNTRACKED: + delta->old_file.flags |= GIT_DIFF_FILE_NO_DATA; + if ((ctxt->opts->flags & GIT_DIFF_INCLUDE_UNTRACKED_CONTENT) == 0) + delta->new_file.flags |= GIT_DIFF_FILE_NO_DATA; + break; default: delta->new_file.flags |= GIT_DIFF_FILE_NO_DATA; delta->old_file.flags |= GIT_DIFF_FILE_NO_DATA; @@ -1070,6 +1078,9 @@ static int print_patch_file( GIT_UNUSED(progress); + if (S_ISDIR(delta->new_file.mode)) + return 0; + if (!oldpfx) oldpfx = DIFF_OLD_PREFIX_DEFAULT; @@ -1134,6 +1145,9 @@ static int print_patch_hunk( { diff_print_info *pi = data; + if (S_ISDIR(d->new_file.mode)) + return 0; + git_buf_clear(pi->buf); if (git_buf_printf(pi->buf, "%.*s", (int)header_len, header) < 0) return -1; @@ -1158,6 +1172,9 @@ static int print_patch_line( { diff_print_info *pi = data; + if (S_ISDIR(delta->new_file.mode)) + return 0; + git_buf_clear(pi->buf); if (line_origin == GIT_DIFF_LINE_ADDITION || |