Select Git revision
diffcore-break.c
-
Junio C Hamano authored
Sprinkle a few diff_debug_queue() to allow inspecting what is going on inside this part of the diffcore chain. Signed-off-by:
Junio C Hamano <gitster@pobox.com>
Junio C Hamano authoredSprinkle a few diff_debug_queue() to allow inspecting what is going on inside this part of the diffcore chain. Signed-off-by:
Junio C Hamano <gitster@pobox.com>
diff-no-index.c 6.91 KiB
/*
* "diff --no-index" support
* Copyright (c) 2007 by Johannes Schindelin
* Copyright (c) 2008 by Junio C Hamano
*/
#include "cache.h"
#include "color.h"
#include "commit.h"
#include "blob.h"
#include "tag.h"
#include "diff.h"
#include "diffcore.h"
#include "revision.h"
#include "log-tree.h"
#include "builtin.h"
#include "string-list.h"
#include "dir.h"
static int read_directory_contents(const char *path, struct string_list *list)
{
DIR *dir;
struct dirent *e;
if (!(dir = opendir(path)))
return error("Could not open directory %s", path);
while ((e = readdir(dir)))
if (!is_dot_or_dotdot(e->d_name))
string_list_insert(list, e->d_name);
closedir(dir);
return 0;
}
/*
* This should be "(standard input)" or something, but it will
* probably expose many more breakages in the way no-index code
* is bolted onto the diff callchain.
*/
static const char file_from_standard_input[] = "-";
static int get_mode(const char *path, int *mode)
{
struct stat st;
if (!path || !strcmp(path, "/dev/null"))
*mode = 0;
#ifdef GIT_WINDOWS_NATIVE
else if (!strcasecmp(path, "nul"))
*mode = 0;
#endif
else if (path == file_from_standard_input)
*mode = create_ce_mode(0666);
else if (lstat(path, &st))
return error("Could not access '%s'", path);
else
*mode = st.st_mode;
return 0;
}
static int populate_from_stdin(struct diff_filespec *s)
{
struct strbuf buf = STRBUF_INIT;
size_t size = 0;
if (strbuf_read(&buf, 0, 0) < 0)
return error("error while reading from stdin %s",
strerror(errno));